diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index dda552d38..7bdfe45da 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -583,7 +583,7 @@ void Notepad_plus::command(int id) hasLineSelection = selStart != selEnd; if (hasLineSelection) { - pair lineRange = _pEditView->getSelectionLinesRange(); + const pair lineRange = _pEditView->getSelectionLinesRange(); // One single line selection is not allowed. if (lineRange.first == lineRange.second) { diff --git a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp index 127a5bcc2..fb60d7e60 100644 --- a/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp +++ b/PowerEditor/src/ScitillaComponent/ScintillaEditView.cpp @@ -2780,6 +2780,13 @@ pair ScintillaEditView::getSelectionLinesRange() const range.first = static_cast(execute(SCI_LINEFROMPOSITION, start)); range.second = static_cast(execute(SCI_LINEFROMPOSITION, end)); + if ((range.first != range.second) && (execute(SCI_POSITIONFROMLINE, range.second) == end)) + { + // if the end of the selection includes the line-ending, + // then don't include the following line in the range + --range.second; + } + return range; }