Skip to content

Commit

Permalink
[vim] fix @@ to rerun last run macro (codemirror#5868)
Browse files Browse the repository at this point in the history
`vimGlobalState.macroModeState.latestRegister` was only ever updated when defining a macro. This change updates it when running a macro too so that `@@` actually repeats the last macro as it does in vim
  • Loading branch information
evanminsk authored and cone56 committed Jan 6, 2020
1 parent f0ae9da commit 8b2f651
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions keymap/vim.js
Original file line number Diff line number Diff line change
Expand Up @@ -2316,6 +2316,8 @@
var macroModeState = vimGlobalState.macroModeState;
if (registerName == '@') {
registerName = macroModeState.latestRegister;
} else {
macroModeState.latestRegister = registerName;
}
while(repeat--){
executeMacroRegister(cm, vim, macroModeState, registerName);
Expand Down
9 changes: 9 additions & 0 deletions test/vim_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2672,6 +2672,15 @@ testVim('macro_last_ex_command_register', function (cm, vim, helpers) {
eq('bbbaa', cm.getValue());
helpers.assertCursorAt(0, 2);
}, { value: 'aaaaa'});
testVim('macro_last_run_macro', function (cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('q', 'a', 'C', 'a', '<Esc>', 'q');
helpers.doKeys('q', 'b', 'C', 'b', '<Esc>', 'q');
helpers.doKeys('@', 'a');
helpers.doKeys('d', 'd');
helpers.doKeys('@', '@');
eq('a', cm.getValue());
}, { value: ''});
testVim('macro_parens', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('q', 'z', 'i');
Expand Down

0 comments on commit 8b2f651

Please sign in to comment.