diff --git a/src/Edit.c b/src/Edit.c index 06674e2a3..392bbc2a9 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -4976,12 +4976,12 @@ void EditSetSelectionEx(DocPos iAnchorPos, DocPos iCurrentPos, DocPos vSpcAnchor if (vSpcCurrent > 0) { SciCall_SetRectangularSelectionCaretVirtualSpace(vSpcCurrent); } + EditEnsureSelectionVisible(); } else { SciCall_SetSel(iAnchorPos, iCurrentPos); // scrolls into view + SciCall_ChooseCaretX(); } - //~EditNormalizeView(Sci_GetCurrentLineNumber()); // normalize view - EditEnsureSelectionVisible(); } //~~~_END_UNDO_ACTION_;~~~ @@ -5022,17 +5022,11 @@ void EditNormalizeView(const DocLn iDocLine) // void EditEnsureSelectionVisible() { - DocPos const posCurrent = SciCall_GetCurrentPos(); - DocPos const posAnchor = SciCall_GetAnchor(); - DocLn const iCurrentLine = SciCall_LineFromPosition(posCurrent); - DocLn const iAnchorLine = SciCall_LineFromPosition(posAnchor); - // Ensure that the first and last lines of a selection are always unfolded - // This needs to be done *before* the SCI_SETSEL message + DocLn const iCurrentLine = SciCall_LineFromPosition(SciCall_GetCurrentPos()); + DocLn const iAnchorLine = SciCall_LineFromPosition(SciCall_GetAnchor()); SciCall_EnsureVisible(iAnchorLine); - if (iAnchorLine != iCurrentLine) { SciCall_EnsureVisible(iCurrentLine); } - - SciCall_ScrollRange(posCurrent, posAnchor); + Sci_ScrollToLine(iCurrentLine); Sci_ScrollChooseCaret(); } diff --git a/src/Notepad3.c b/src/Notepad3.c index 346f06a1a..d4050618c 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -4885,7 +4885,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) DocPosU const iNewMain = SciCall_GetSelections() - 1; SciCall_SetMainSelection(iNewMain); } - //EditNormalizeView(Sci_GetCurrentLineNumber()); // normalize view + //~EditNormalizeView(Sci_GetCurrentLineNumber()); EditEnsureSelectionVisible(); } break; @@ -5304,7 +5304,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) FileWatching.AutoReloadTimeout = Settings2.AutoReloadTimeout; UndoRedoRecordingStart(); SciCall_SetEndAtLastLine(!Settings.ScrollPastEOF); - EditNormalizeView(Sci_GetCurrentLineNumber()); // normalize view + EditNormalizeView(Sci_GetCurrentLineNumber()); } InstallFileWatching(Globals.CurrentFile); // force @@ -9517,9 +9517,7 @@ bool FileLoad(bool bDontSave, bool bNew, bool bReload, // set historic caret/selection pos else if ((iCaretPos >= 0) && (iAnchorPos >= 0)) { - SciCall_SetSel(iAnchorPos, iCaretPos); // scroll into view - //~EditNormalizeView(Sci_GetCurrentLineNumber()); - EditEnsureSelectionVisible(); + EditSetSelectionEx(iAnchorPos, iCaretPos, 0, 0); } }