+ fix: minor enhancements for selection scroll to view

This commit is contained in:
Rainer Kottenhoff 2021-05-13 15:29:00 +02:00
parent b8bf6f8ae6
commit d2e8537e25
4 changed files with 7 additions and 16 deletions

View File

@ -1431,7 +1431,9 @@ bool EditSaveFile(
// ensure consistent line endings
if (Settings.FixLineEndings) {
BeginWaitCursorUID(true, IDS_MUI_SB_CONV_LNBRK);
EditEnsureConsistentLineEndings(hwnd);
EndWaitCursor();
}
// strip trailing blanks
@ -3255,11 +3257,8 @@ void EditIndentBlock(HWND hwnd, int cmd, bool bFormatIndentation, bool bForceAll
//~~~UndoTransActionBegin(); ~ do outside
DocPos const iInitialPos = SciCall_GetCurrentPos();
if (bForceAll) {
SciCall_SelectAll();
SciCall_SwapMainAnchorCaret();
}
DocPos const iCurPos = SciCall_GetCurrentPos();
@ -3323,9 +3322,8 @@ void EditIndentBlock(HWND hwnd, int cmd, bool bFormatIndentation, bool bForceAll
}
EditSetSelectionEx(SciCall_GetLineEndPosition(iAnchorLine) - iDiffAnchor, SciCall_GetLineEndPosition(iCurLine) - iDiffCurrent, -1, -1);
}
//EditScrollSelectionToView();
} else {
Sci_GotoPosChooseCaret(iInitialPos);
Sci_ScrollChooseCaret();
}
//~~~EndUndoTransAction(); ~ do outside
@ -5362,10 +5360,7 @@ void EditSetSelectionEx(DocPos iAnchorPos, DocPos iCurrentPos, DocPos vSpcAnchor
//
void EditEnsureConsistentLineEndings(HWND hwnd)
{
IgnoreNotifyDocChangedEvent(true);
SciCall_ConvertEOLs(SciCall_GetEOLMode());
ObserveNotifyDocChangedEvent();
Globals.bDocHasInconsistentEOLs = false;
EditFixPositions(hwnd);
}

View File

@ -4310,8 +4310,8 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam)
case IDM_LINEENDINGS_CRLF:
case IDM_LINEENDINGS_CR:
case IDM_LINEENDINGS_LF: {
BeginWaitCursorUID(true, IDS_MUI_SB_CONV_LNBRK);
int const _eol_mode = (iLoWParam - IDM_LINEENDINGS_CRLF); // SC_EOL_CRLF(0), SC_EOL_CR(1), SC_EOL_LF(2)
BeginWaitCursorUID(true, IDS_MUI_SB_CONV_LNBRK);
SciCall_SetEOLMode(_eol_mode);
EditEnsureConsistentLineEndings(Globals.hwndEdit);
EndWaitCursor();
@ -9561,7 +9561,6 @@ bool RestoreAction(int token, DoAction doAct)
PostMessage(hwndedit, SCI_ENSUREVISIBLE, currPosLine, 0);
}
int const selectionMode = (UNDO == doAct) ? pSel->selMode_undo : pSel->selMode_redo;
PostMessage(hwndedit, SCI_SETSELECTIONMODE, (WPARAM)((selectionMode == NP3_SEL_MULTI) ? SC_SEL_STREAM : selectionMode), 0);
@ -9620,7 +9619,7 @@ bool RestoreAction(int token, DoAction doAct)
break;
}
}
PostMessage(hwndedit, SCI_SCROLLCARET, 0, 0);
PostMessage(hwndedit, SCI_SCROLLRANGE, (WPARAM)(*pPosAnchor), (LPARAM)(*pPosCur));
PostMessage(hwndedit, SCI_CHOOSECARETX, 0, 0);
}
return true;

View File

@ -191,10 +191,7 @@ void ObserveNotifyDocChangedEvent();
// ----------------------------------------------------------------------------
#define DocChangeTransactionBegin() \
__try { \
SciCall_BeginUndoAction(); \
IgnoreNotifyDocChangedEvent(false);
#define DocChangeTransactionBegin() __try { SciCall_BeginUndoAction(); IgnoreNotifyDocChangedEvent(false);
#define EndDocChangeTransaction() } __finally { ObserveNotifyDocChangedEvent(); SciCall_EndUndoAction(); }
// ----------------------------------------------------------------------------

View File

@ -758,7 +758,7 @@ inline void Sci_ScrollToLine(const DocLn line)
if (!SciCall_GetLineVisible(line)) {
SciCall_EnsureVisible(line);
}
SciCall_ScrollRange(SciCall_PositionFromLine(line), SciCall_GetLineEndPosition(line));
SciCall_ScrollRange(SciCall_GetLineEndPosition(line), SciCall_PositionFromLine(line));
}
inline void Sci_ScrollToCurrentLine()
{