From 8b93240c59526f3d80c9c2a2b15e804ca82abbb4 Mon Sep 17 00:00:00 2001 From: Scott Sumner <30118311+sasumner@users.noreply.github.com> Date: Wed, 1 Jul 2020 19:36:45 -0400 Subject: [PATCH] Fix condition where Join Lines does one too many lines Fix #8503, close #8506 --- PowerEditor/src/NppCommands.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 0ec8646a6..cc6875a26 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -1438,9 +1438,18 @@ void Notepad_plus::command(int id) break; case IDM_EDIT_JOIN_LINES: - _pEditView->execute(SCI_TARGETFROMSELECTION); - _pEditView->execute(SCI_LINESJOIN); - break; + { + const pair lineRange = _pEditView->getSelectionLinesRange(); + if (lineRange.first != lineRange.second) + { + auto anchorPos = _pEditView->execute(SCI_POSITIONFROMLINE, lineRange.first); + auto caretPos = _pEditView->execute(SCI_GETLINEENDPOSITION, lineRange.second); + _pEditView->execute(SCI_SETSELECTION, caretPos, anchorPos); + _pEditView->execute(SCI_TARGETFROMSELECTION); + _pEditView->execute(SCI_LINESJOIN); + } + } + break; case IDM_EDIT_LINE_UP: _pEditView->currentLinesUp();