From 981ee5ed724f59afbf30297085a83474b891e4f4 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Wed, 7 Oct 2015 17:55:29 +0200 Subject: [PATCH] Fix macro playback inseting/removing characters randomly. Fix macro playback inseting/removing characters randomly due to auto-insert interfering during macro recording and playing back. (fixes #649, fixes #970, fixes #304, fixes #992) --- PowerEditor/src/Notepad_plus.h | 1 + PowerEditor/src/NppCommands.cpp | 4 ++++ PowerEditor/src/NppNotification.cpp | 22 ++++++++++++---------- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/PowerEditor/src/Notepad_plus.h b/PowerEditor/src/Notepad_plus.h index 231e17c36..8486dfb72 100644 --- a/PowerEditor/src/Notepad_plus.h +++ b/PowerEditor/src/Notepad_plus.h @@ -369,6 +369,7 @@ private: // Keystroke macro recording and playback Macro _macro; bool _recordingMacro = false; + bool _playingBackMacro = false; RunMacroDlg _runMacroDlg; // For hotspot diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index 7ea390c30..a9c95b1b0 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -637,7 +637,11 @@ void Notepad_plus::command(int id) case IDM_MACRO_PLAYBACKRECORDEDMACRO: if (!_recordingMacro) // if we're not currently recording, then playback the recorded keystrokes + { + _playingBackMacro = true; macroPlayback(_macro); + _playingBackMacro = false; + } break; case IDM_MACRO_RUNMULTIMACRODLG : diff --git a/PowerEditor/src/NppNotification.cpp b/PowerEditor/src/NppNotification.cpp index 3937dc4bb..ca3831536 100644 --- a/PowerEditor/src/NppNotification.cpp +++ b/PowerEditor/src/NppNotification.cpp @@ -515,17 +515,19 @@ BOOL Notepad_plus::notify(SCNotification *notification) case SCN_CHARADDED: { - const NppGUI & nppGui = NppParameters::getInstance()->getNppGUI(); - bool indentMaintain = nppGui._maitainIndent; - if (indentMaintain) - maintainIndentation(static_cast(notification->ch)); - - AutoCompletion * autoC = isFromPrimary?&_autoCompleteMain:&_autoCompleteSub; - bool isColumnMode = _pEditView->execute(SCI_GETSELECTIONS) > 1; // Multi-Selection || Column mode) - if (nppGui._matchedPairConf.hasAnyPairsPair() && !isColumnMode) - autoC->insertMatchedChars(notification->ch, nppGui._matchedPairConf); - autoC->update(notification->ch); + if (!_recordingMacro && !_playingBackMacro) // No macro recording or playing back + { + const NppGUI & nppGui = NppParameters::getInstance()->getNppGUI(); + bool indentMaintain = nppGui._maitainIndent; + if (indentMaintain) + maintainIndentation(static_cast(notification->ch)); + AutoCompletion * autoC = isFromPrimary ? &_autoCompleteMain : &_autoCompleteSub; + bool isColumnMode = _pEditView->execute(SCI_GETSELECTIONS) > 1; // Multi-Selection || Column mode) + if (nppGui._matchedPairConf.hasAnyPairsPair() && !isColumnMode) + autoC->insertMatchedChars(notification->ch, nppGui._matchedPairConf); + autoC->update(notification->ch); + } break; }