From bfa44f5db3e83461ea008667f2e26a4f4b65dfb0 Mon Sep 17 00:00:00 2001 From: Scott Sumner <30118311+sasumner@users.noreply.github.com> Date: Sat, 14 Nov 2020 08:19:51 -0500 Subject: [PATCH] Fix bug where -p0 cmd line arg causes wrong positioning Fixes small bug introduced by #9143. Close #9150 --- PowerEditor/src/Notepad_plus.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.cpp b/PowerEditor/src/Notepad_plus.cpp index 626b64f1..9b50f923 100644 --- a/PowerEditor/src/Notepad_plus.cpp +++ b/PowerEditor/src/Notepad_plus.cpp @@ -5925,10 +5925,13 @@ std::vector Notepad_plus::loadCommandlineParams(const TCHAR * co if (cpos != -1) { - // make sure not jumping into the middle of a multibyte character - // or into the middle of a CR/LF pair for Windows files - auto before = _pEditView->execute(SCI_POSITIONBEFORE, cpos); - cpos = static_cast(_pEditView->execute(SCI_POSITIONAFTER, before)); + if (cpos > 0) + { + // make sure not jumping into the middle of a multibyte character + // or into the middle of a CR/LF pair for Windows files + auto before = _pEditView->execute(SCI_POSITIONBEFORE, cpos); + cpos = static_cast(_pEditView->execute(SCI_POSITIONAFTER, before)); + } _pEditView->execute(SCI_GOTOPOS, cpos); } else if (cn == -1)