From 91074da46d2d0110b151e8d31aeb4b872ebaf77c Mon Sep 17 00:00:00 2001 From: anatoly77g <156801816+anatoly77g@users.noreply.github.com> Date: Wed, 17 Jan 2024 19:50:13 +0200 Subject: [PATCH] Fix macro recording twice for some commands When recording a keyboard macro, some commands are added to the macro twice. When later playing back the macro, they happen twice, which leads to incorrect edits. Fixed commands: * EDIT_CUT (Cut) * EDIT_COPY (Copy) * IDM_EDIT_LINE_UP (Move Up Current Line) * IDM_EDIT_LINE_DOWN (Move Down Current Line) Not fixed: issue 13722: SEARCH_GOTOMATCHINGBRACE (Go to Matching Brace) Fix #5217, fix #14634, close #14613 --- PowerEditor/src/NppCommands.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/PowerEditor/src/NppCommands.cpp b/PowerEditor/src/NppCommands.cpp index e18c92826..863e022d8 100644 --- a/PowerEditor/src/NppCommands.cpp +++ b/PowerEditor/src/NppCommands.cpp @@ -4200,9 +4200,6 @@ void Notepad_plus::command(int id) case IDM_FILE_RELOAD: case IDM_EDIT_UNDO: case IDM_EDIT_REDO: - case IDM_EDIT_CUT: - case IDM_EDIT_COPY: - //case IDM_EDIT_PASTE: case IDM_EDIT_DELETE: case IDM_SEARCH_FINDNEXT : case IDM_SEARCH_FINDPREV : @@ -4224,8 +4221,6 @@ void Notepad_plus::command(int id) case IDM_EDIT_TRANSPOSE_LINE: case IDM_EDIT_SPLIT_LINES: case IDM_EDIT_JOIN_LINES: - case IDM_EDIT_LINE_UP: - case IDM_EDIT_LINE_DOWN: case IDM_EDIT_REMOVEEMPTYLINES: case IDM_EDIT_REMOVEEMPTYLINESWITHBLANK: case IDM_EDIT_UPPERCASE: @@ -4379,6 +4374,14 @@ void Notepad_plus::command(int id) _macro.push_back(recordedMacroStep(id)); break; + // No need to record the following commands: all they do is execute Scintilla commands, which are recorded instead. + case IDM_EDIT_CUT: + case IDM_EDIT_COPY: + case IDM_EDIT_PASTE: + case IDM_EDIT_LINE_UP: + case IDM_EDIT_LINE_DOWN: + break; + // The following 3 commands will insert date time string during the recording: // SCI_REPLACESEL will be recorded firstly, then SCI_ADDTEXT (for adding date time string) // So we erase these 2 unwanted commanded for recording these 3 following commands.