diff --git a/Versions/build.txt b/Versions/build.txt index 45c4a6b22..d00194588 100644 --- a/Versions/build.txt +++ b/Versions/build.txt @@ -1 +1 @@ -2599 +2601 diff --git a/res/Notepad3.exe.manifest.conf b/res/Notepad3.exe.manifest.conf index dbb9431b9..d25f82f33 100644 --- a/res/Notepad3.exe.manifest.conf +++ b/res/Notepad3.exe.manifest.conf @@ -3,7 +3,7 @@ Notepad3 BETA diff --git a/src/Config/Config.cpp b/src/Config/Config.cpp index 8c06018c3..2fb0292d5 100644 --- a/src/Config/Config.cpp +++ b/src/Config/Config.cpp @@ -631,10 +631,8 @@ void LoadSettings() FileWatching.AutoReloadTimeout = Settings2.AutoReloadTimeout; Defaults2.UndoRedoSplitTimeout = 0UL; - Settings2.UndoRedoSplitTimeout = IniSectionGetInt(Settings2_Section, L"UndoRedoSplitTimeout", Defaults2.UndoRedoSplitTimeout); - if (Settings2.UndoRedoSplitTimeout != 0) { - Settings2.UndoRedoSplitTimeout = clampul(Settings2.UndoRedoSplitTimeout, 100UL, 86400000UL); // max: 24h - } + Settings2.UndoRedoSplitTimeout = clampul(IniSectionGetInt(Settings2_Section, L"UndoRedoSplitTimeout", + Defaults2.UndoRedoSplitTimeout), 0UL, 86400000UL); // deprecated Defaults.RenderingTechnology = IniSectionGetInt(Settings2_Section, L"SciDirectWriteTech", -111); diff --git a/src/Notepad3.c b/src/Notepad3.c index e049ac8b9..9b706dbdb 100644 --- a/src/Notepad3.c +++ b/src/Notepad3.c @@ -386,6 +386,7 @@ static bool _InUndoRedoTransaction(); static void _SaveRedoSelection(int token); static int _SaveUndoSelection(); static int _UndoRedoActionMap(int token, UndoRedoSelection_t** selection); +static void _SplitUndoTransaction(); // ---------------------------------------------------------------------------- @@ -459,6 +460,7 @@ static int msgcmp(void* mqc1, void* mqc2) } // ---------------------------------------------------------------------------- +#define _MQ_IMMEDIATE (2 * USER_TIMER_MINIMUM - 1) #define _MQ_ms(T) ((T) / USER_TIMER_MINIMUM) static void _MQ_AppendCmd(CmdMessageQueue_t* const pMsgQCmd, int cycles) @@ -3482,8 +3484,7 @@ LRESULT MsgCommand(HWND hwnd, UINT umsg, WPARAM wParam, LPARAM lParam) break; case IDT_TIMER_UNDO_REDO_SPLIT: - SciCall_BeginUndoAction(); - SciCall_EndUndoAction(); + _SplitUndoTransaction(); break; @@ -6976,9 +6977,6 @@ inline static LRESULT _MsgNotifyLean(const LPNMHDR pnmh, const SCNotification* c _SaveRedoSelection(_SaveUndoSelection()); } } - if (Settings2.UndoRedoSplitTimeout != 0) { - _DelayUndoRedoTypingSequenceSplit(Settings2.UndoRedoSplitTimeout); - } bModified = false; // not yet } // check for ADDUNDOACTION step @@ -6991,7 +6989,20 @@ inline static LRESULT _MsgNotifyLean(const LPNMHDR pnmh, const SCNotification* c RestoreAction(scn->token, REDO); } } - if (bModified) { _SetSaveNeededFlag(true); } + if (bModified) { + DWORD const timeout = Settings2.UndoRedoSplitTimeout; + if (timeout != 0UL) { + if (timeout > _MQ_IMMEDIATE) { + _DelayUndoRedoTypingSequenceSplit(timeout); + } + else { + if (!((iModType & SC_PERFORMED_UNDO) || (iModType & SC_PERFORMED_REDO))) { + _SplitUndoTransaction(); + } + } + } + _SetSaveNeededFlag(true); + } } else if (pnmh->code == SCN_SAVEPOINTREACHED) { _SetSaveNeededFlag(false); @@ -7063,9 +7074,6 @@ static LRESULT _MsgNotifyFromEdit(HWND hwnd, const LPNMHDR pnmh, const SCNotific _SaveRedoSelection(_SaveUndoSelection()); } } - if (Settings2.UndoRedoSplitTimeout != 0) { - _DelayUndoRedoTypingSequenceSplit(Settings2.UndoRedoSplitTimeout); - } bModified = false; // not yet } if (iModType & SC_MOD_CONTAINER) { @@ -7083,8 +7091,22 @@ static LRESULT _MsgNotifyFromEdit(HWND hwnd, const LPNMHDR pnmh, const SCNotific UpdateVisibleHotspotIndicators(); if (scn->linesAdded != 0) { + if (Settings.SplitUndoTypingSeqOnLnBreak) { + _SplitUndoTransaction(); + } UpdateMarginWidth(); } + DWORD const timeout = Settings2.UndoRedoSplitTimeout; + if (timeout != 0UL) { + if (timeout > _MQ_IMMEDIATE) { + _DelayUndoRedoTypingSequenceSplit(timeout); + } + else { + if (!((iModType & SC_PERFORMED_UNDO) || (iModType & SC_PERFORMED_REDO))) { + _SplitUndoTransaction(); + } + } + } _SetSaveNeededFlag(true); } @@ -7212,7 +7234,6 @@ static LRESULT _MsgNotifyFromEdit(HWND hwnd, const LPNMHDR pnmh, const SCNotific switch (ich) { case '\r': case '\n': - if (Settings.SplitUndoTypingSeqOnLnBreak) { SciCall_BeginUndoAction(); SciCall_EndUndoAction(); } if (Settings.AutoIndent) { _HandleAutoIndent(ich); } break; case '>': @@ -9286,6 +9307,19 @@ static int _UndoRedoActionMap(int token, UndoRedoSelection_t** selection) } +//============================================================================= +// +// _SplitUndoTransaction() +// +// +static void _SplitUndoTransaction() { + if (!_InUndoRedoTransaction()) { + SciCall_BeginUndoAction(); + SciCall_EndUndoAction(); + } +} + + //============================================================================= // // FileIO() diff --git a/src/VersionEx.h b/src/VersionEx.h index ce0de48aa..49139491c 100644 --- a/src/VersionEx.h +++ b/src/VersionEx.h @@ -8,7 +8,7 @@ #define VERSION_MAJOR 5 #define VERSION_MINOR 19 #define VERSION_REV 827 -#define VERSION_BUILD 2599 +#define VERSION_BUILD 2601 #define SCINTILLA_VER 420 #define ONIGURUMA_REGEX_VER 6.9.3 #define UCHARDET_VER 2018.09.27