parent
08190bbe96
commit
210ae7e1d3
@ -3623,26 +3623,23 @@ generic_string & Finder::prepareStringForClipboard(generic_string & s) const
|
||||
|
||||
void Finder::copy()
|
||||
{
|
||||
if (_scintView.execute(SCI_GETSELECTIONS) > 1) // multi-selection
|
||||
{
|
||||
// don't do anything if user has made a column/rectangular selection
|
||||
return;
|
||||
}
|
||||
|
||||
size_t fromLine, toLine;
|
||||
{
|
||||
const auto selStart = _scintView.execute(SCI_GETSELECTIONSTART);
|
||||
const auto selEnd = _scintView.execute(SCI_GETSELECTIONEND);
|
||||
const bool hasSelection = selStart != selEnd;
|
||||
const pair<int, int> lineRange = _scintView.getSelectionLinesRange();
|
||||
if (hasSelection && lineRange.first != lineRange.second)
|
||||
{
|
||||
fromLine = lineRange.first;
|
||||
toLine = lineRange.second;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Abuse fold levels to find out which lines to copy to clipboard.
|
||||
// We get the current line and then the next line which has a smaller fold level (SCI_GETLASTCHILD).
|
||||
// Then we loop all lines between them and determine which actually contain search results.
|
||||
fromLine = _scintView.getCurrentLineNumber();
|
||||
const int selectedLineFoldLevel = _scintView.execute(SCI_GETFOLDLEVEL, fromLine) & SC_FOLDLEVELNUMBERMASK;
|
||||
toLine = _scintView.execute(SCI_GETLASTCHILD, fromLine, selectedLineFoldLevel);
|
||||
}
|
||||
fromLine = lineRange.first;
|
||||
toLine = lineRange.second;
|
||||
|
||||
// Abuse fold levels to find out which lines to copy to clipboard.
|
||||
// We get the current line and then the next line which has a smaller fold level (SCI_GETLASTCHILD).
|
||||
// Then we loop all lines between them and determine which actually contain search results.
|
||||
const int selectedLineFoldLevel = _scintView.execute(SCI_GETFOLDLEVEL, fromLine) & SC_FOLDLEVELNUMBERMASK;
|
||||
toLine = _scintView.execute(SCI_GETLASTCHILD, toLine, selectedLineFoldLevel);
|
||||
}
|
||||
|
||||
std::vector<generic_string> lines;
|
||||
@ -3659,7 +3656,7 @@ void Finder::copy()
|
||||
}
|
||||
}
|
||||
}
|
||||
const generic_string toClipboard = stringJoin(lines, TEXT("\r\n"));
|
||||
const generic_string toClipboard = stringJoin(lines, TEXT("\r\n")) + TEXT("\r\n");
|
||||
if (!toClipboard.empty())
|
||||
{
|
||||
if (!str2Clipboard(toClipboard, _hSelf))
|
||||
|
Loading…
Reference in New Issue
Block a user