Fix dot repeat after exiting Visual modes or command line (#8090)

Fixes #7627
This commit is contained in:
wgr45097 2022-12-06 09:14:27 +08:00 committed by GitHub
parent 974ba70fa4
commit 63bb90947b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View File

@ -797,6 +797,18 @@ export class ModeHandler implements vscode.Disposable, IModeHandler {
(ranRepeatableAction && this.vimState.currentMode === Mode.Normal) ||
this.createUndoPointForBrackets();
// We don't want to record a repeatable action when exiting from these modes
// by pressing <Esc>
if (
(prevMode === Mode.Visual ||
prevMode === Mode.VisualBlock ||
prevMode === Mode.VisualLine ||
prevMode === Mode.CommandlineInProgress) &&
action.keysPressed[0] === '<Esc>'
) {
ranRepeatableAction = false;
}
// Record down previous action and flush temporary state
if (ranRepeatableAction && this.vimState.lastCommandDotRepeatable) {
globalState.previousFullAction = this.vimState.recordedState;

View File

@ -218,6 +218,20 @@ suite('Repeat content change', () => {
keysPressed: 'a<C-t>b<left>c<Esc>j.',
end: ['\tonecb', 'tw|co'],
});
newTest({
title: 'Can repeat change after v<Esc> and :<Esc>',
start: ['aaa bbb ccc dd|d'],
keysPressed: 'ciwxxx<Esc>' + 'bb.' + 'bbv<Esc>.' + 'bb:<Esc>.',
end: ['xx|x xxx xxx xxx'],
});
newTest({
title: 'Can repeat change after V<Esc> and <C-q><Esc>',
start: ['aaa bbb ccc dd|d'],
keysPressed: 'ciwxxx<Esc>' + 'bb.' + 'bbV<Esc>.' + 'bb<C-q><Esc>.',
end: ['xx|x xxx xxx xxx'],
});
});
suite('Dot Operator repeat with remap', () => {