mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-10-26 20:23:50 +03:00
commit
69e3b18c99
@ -181,6 +181,11 @@
|
||||
"command": "extension.vim_ctrl+a",
|
||||
"when": "editorTextFocus && vim.useCtrlKeys && !inDebugRepl"
|
||||
},
|
||||
{
|
||||
"key": "ctrl+o",
|
||||
"command": "extension.vim_ctrl+o",
|
||||
"when": "editorTextFocus && vim.useCtrlKeys && !inDebugRepl"
|
||||
},
|
||||
{
|
||||
"key": "ctrl+x",
|
||||
"command": "extension.vim_ctrl+x",
|
||||
|
@ -664,6 +664,17 @@ class CommandInsertRegisterContent extends BaseCommand {
|
||||
|
||||
}
|
||||
|
||||
@RegisterAction
|
||||
export class CommandOneNormalCommandInInsertMode extends BaseCommand {
|
||||
modes = [ModeName.Insert];
|
||||
keys = ["<C-o>"];
|
||||
|
||||
public async exec(position: Position, vimState: VimState): Promise<VimState> {
|
||||
vimState.returnToInsertAfterCommand = true;
|
||||
return await new CommandEscInsertMode().exec(position, vimState);
|
||||
}
|
||||
}
|
||||
|
||||
@RegisterAction
|
||||
class CommandInsertRegisterContentInSearchMode extends BaseCommand {
|
||||
modes = [ModeName.SearchInProgressMode];
|
||||
|
@ -98,6 +98,12 @@ export class VimState {
|
||||
|
||||
public focusChanged = false;
|
||||
|
||||
/**
|
||||
* Used for command like <C-o> which allows you to return to insert after a command
|
||||
*/
|
||||
public returnToInsertAfterCommand = false;
|
||||
public actionCount = 0;
|
||||
|
||||
/**
|
||||
* Every time we invoke a VS Code command which might trigger Code's view update,
|
||||
* we should postpone its view updating phase to avoid conflicting with our internal view updating mechanism.
|
||||
@ -822,6 +828,18 @@ export class ModeHandler implements vscode.Disposable {
|
||||
|
||||
if (ranAction) {
|
||||
vimState.recordedState = new RecordedState();
|
||||
|
||||
// Return to insert mode after 1 command in this case for <C-o>
|
||||
if (vimState.returnToInsertAfterCommand) {
|
||||
if (vimState.actionCount > 0) {
|
||||
vimState.currentMode = ModeName.Insert;
|
||||
vimState.returnToInsertAfterCommand = false;
|
||||
vimState.actionCount = 0;
|
||||
this.setCurrentModeByName(vimState);
|
||||
} else {
|
||||
vimState.actionCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// track undo history
|
||||
|
@ -4,13 +4,18 @@ import {setupWorkspace, cleanUpWorkspace, assertEqualLines, assertEqual} from '.
|
||||
import {ModeName} from '../../src/mode/mode';
|
||||
import {TextEditor} from '../../src/textEditor';
|
||||
import {ModeHandler} from "../../src/mode/modeHandler";
|
||||
import { getTestingFunctions } from '../testSimplifier';
|
||||
|
||||
suite("Mode Insert", () => {
|
||||
let modeHandler: ModeHandler;
|
||||
let modeHandler: ModeHandler = new ModeHandler();
|
||||
|
||||
let {
|
||||
newTest,
|
||||
newTestOnly,
|
||||
} = getTestingFunctions(modeHandler);
|
||||
|
||||
setup(async () => {
|
||||
await setupWorkspace();
|
||||
|
||||
modeHandler = new ModeHandler();
|
||||
});
|
||||
|
||||
@ -168,4 +173,12 @@ suite("Mode Insert", () => {
|
||||
|
||||
assertEqualLines([" "]);
|
||||
});
|
||||
|
||||
newTest({
|
||||
title: "Can perform <ctrl+o> to exit and perform one command in normal",
|
||||
start: ['testtest|'],
|
||||
keysPressed: 'a123<C-o>b123',
|
||||
end: ['123|testtest123']
|
||||
});
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user