From daa31c1a9a025eccb20d0de2c419adc198df15f4 Mon Sep 17 00:00:00 2001 From: Don HO Date: Sat, 14 Nov 2020 11:34:19 +0100 Subject: [PATCH] Fix "Go to..." dialog wrong Offset value in empty files Fix #9145 --- PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp b/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp index ec0735cb..e889115d 100644 --- a/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp +++ b/PowerEditor/src/ScitillaComponent/GoToLineDlg.cpp @@ -108,6 +108,7 @@ INT_PTR CALLBACK GoToLineDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM) updateLinesNumbers(); return TRUE; } + default : { switch (HIWORD(wParam)) @@ -142,7 +143,8 @@ void GoToLineDlg::updateLinesNumbers() const else { current = static_cast((*_ppEditView)->execute(SCI_GETCURRENTPOS)); - limit = static_cast((*_ppEditView)->getCurrentDocLen() - 1); + int currentDocLength = (*_ppEditView)->getCurrentDocLen(); + limit = static_cast(currentDocLength > 0 ? currentDocLength - 1 : 0); } ::SetDlgItemInt(_hSelf, ID_CURRLINE, current, FALSE); ::SetDlgItemInt(_hSelf, ID_LASTLINE, limit, FALSE);