Disallow Goto dlg offset option from moving to position inside multibyte char or between CR and LF

Fix #9101, fix #9125, close #9129
pull/9150/head
Scott Sumner 4 years ago committed by Don HO
parent f75f8b8d40
commit f027e9271d

@ -62,9 +62,17 @@ 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<int>((*_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);
}
}

Loading…
Cancel
Save