From 1a9f19d961781baa26dc49bde4dad00236757be8 Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 16 Aug 2017 21:40:55 +0200 Subject: [PATCH] + fix: restore selection after undo: revert selection mode too --- src/Notepad3.c | 11 +++++++---- src/Notepad3.h | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Notepad3.c b/src/Notepad3.c index 1e95926fd..0d1d3eaa1 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -5443,7 +5443,7 @@ LRESULT MsgNotify(HWND hwnd,WPARAM wParam,LPARAM lParam) { if (scn->modificationType & SC_PERFORMED_UNDO) { - ResroreSelectionAction(scn->token); + RestoreSelectionAction(scn->token); } //else if (scn->modificationType & SC_PERFORMED_REDO) { // REDO of ADDUNDOACTION step @@ -7029,22 +7029,25 @@ void EndSelUndoAction(int token) //============================================================================= // -// ResroreSelectionAction() +// RestoreSelectionAction() // // -void ResroreSelectionAction(int token) +void RestoreSelectionAction(int token) { UndoRedoSelection sel = { -1,-1,-1 }; if (UndoSelectionMap(token, &sel) >= 0) { // we are inside undo transaction, so do delayed PostMessage() instead of SendMessage() + int currSelMode = (int)SendMessage(hwndEdit, SCI_GETSELECTIONMODE, 0, 0); PostMessage(hwndEdit, SCI_SETSELECTIONMODE, (WPARAM)sel.selMode, 0); - if (sel.selMode == SC_SEL_RECTANGLE) { + if (sel.selMode == SC_SEL_RECTANGLE) + { PostMessage(hwndEdit, SCI_SETRECTANGULARSELECTIONANCHOR, (WPARAM)sel.anchorPos, 0); PostMessage(hwndEdit, SCI_SETRECTANGULARSELECTIONCARET, (WPARAM)sel.currPos, 0); } else { PostMessage(hwndEdit, SCI_SETSELECTION, (WPARAM)sel.currPos, (LPARAM)sel.anchorPos); } + PostMessage(hwndEdit, SCI_SETSELECTIONMODE, (WPARAM)currSelMode, 0); } } diff --git a/src/Notepad3.h b/src/Notepad3.h index ff4883115..7fe64bddb 100644 --- a/src/Notepad3.h +++ b/src/Notepad3.h @@ -135,7 +135,7 @@ void UpdateSettingsCmds(); void InvalidateSelections(); int BeginSelUndoAction(); void EndSelUndoAction(int); -void ResroreSelectionAction(int); +void RestoreSelectionAction(int); int UndoSelectionMap(int, LPUndoRedoSelection);