diff --git a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp index 59cbfe952..bc3e2a38c 100644 --- a/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/FindReplaceDlg.cpp @@ -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 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 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))