diff --git a/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp b/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp index 6770c3c0c..ec0735cba 100644 --- a/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp @@ -62,11 +62,19 @@ INT_PTR CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) } else { - auto sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, line); + int posToGoto = 0; + if (line > 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 = (*_ppEditView)->execute(SCI_POSITIONBEFORE, line); + posToGoto = static_cast((*_ppEditView)->execute(SCI_POSITIONAFTER, before)); + } + auto sci_line = (*_ppEditView)->execute(SCI_LINEFROMPOSITION, posToGoto); (*_ppEditView)->execute(SCI_ENSUREVISIBLE, sci_line); - (*_ppEditView)->execute(SCI_GOTOPOS, line); + (*_ppEditView)->execute(SCI_GOTOPOS, posToGoto); } - } + } SCNotification notification = {}; notification.nmhdr.code = SCN_PAINTED;