Fix Find-result rclick-Copy incomplete data bug

Fix #8801, close #8808
This commit is contained in:
Scott Sumner 2020-09-03 16:56:48 -04:00 committed by Don HO
parent 08190bbe96
commit 210ae7e1d3
No known key found for this signature in database
GPG Key ID: 6C429F1D8D84F46E

View File

@ -3623,26 +3623,23 @@ generic_string & Finder::prepareStringForClipboard(generic_string & s) const
void Finder::copy() 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; 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(); const pair<int, int> lineRange = _scintView.getSelectionLinesRange();
if (hasSelection && lineRange.first != lineRange.second)
{
fromLine = lineRange.first; fromLine = lineRange.first;
toLine = lineRange.second; toLine = lineRange.second;
}
else
{
// Abuse fold levels to find out which lines to copy to clipboard. // 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). // 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. // 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; const int selectedLineFoldLevel = _scintView.execute(SCI_GETFOLDLEVEL, fromLine) & SC_FOLDLEVELNUMBERMASK;
toLine = _scintView.execute(SCI_GETLASTCHILD, fromLine, selectedLineFoldLevel); toLine = _scintView.execute(SCI_GETLASTCHILD, toLine, selectedLineFoldLevel);
}
} }
std::vector<generic_string> lines; 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 (!toClipboard.empty())
{ {
if (!str2Clipboard(toClipboard, _hSelf)) if (!str2Clipboard(toClipboard, _hSelf))