Fix A/I with dot.

This commit is contained in:
johnfn 2016-06-21 00:22:34 -07:00
parent 50568f9aae
commit 50e682f3fd
4 changed files with 31 additions and 2 deletions

View File

@ -495,7 +495,7 @@ class CommandInsertInInsertMode extends BaseCommand {
if (char === "<backspace>") {
await TextEditor.delete(new vscode.Range(position, position.getLeft()));
} else {
await TextEditor.insert(char);
await TextEditor.insert(char, vimState.cursorPosition);
}
vimState.cursorStartPosition = Position.FromVSCodePosition(vscode.window.activeTextEditor.selection.start);

View File

@ -2,9 +2,14 @@
import * as vscode from "vscode";
import { ModeHandler } from './mode/modeHandler';
import { Position } from './motion/position';
export class TextEditor {
static async insert(text: string): Promise<boolean> {
static async insert(text: string, at: Position = undefined): Promise<boolean> {
if (at) {
vscode.window.activeTextEditor.selection = new vscode.Selection(at, at);
}
if (ModeHandler.IsTesting) {
return vscode.window.activeTextEditor.edit(editBuilder => {
editBuilder.insert(vscode.window.activeTextEditor.selection.active, text);

View File

@ -10,6 +10,7 @@ suite("Mode Normal", () => {
let {
newTest,
newTestOnly
} = getTestingFunctions(modeHandler);
setup(async () => {
@ -560,4 +561,18 @@ suite("Mode Normal", () => {
keysPressed: '2gg',
end: ['one', '|two', 'three']
});
newTest({
title: "Can handle dot with A",
start: ['|one', 'two', 'three'],
keysPressed: 'A!<esc>j.j.',
end: ['one!', 'two!', 'three|!']
});
newTest({
title: "Can handle dot with I",
start: ['on|e', 'two', 'three'],
keysPressed: 'I!<esc>j.j.',
end: ['!one', '!two', '|!three']
});
});

View File

@ -197,6 +197,15 @@ async function testIt(modeHandler: ModeHandler, testObj: ITestObject): Promise<v
//
let actualPosition = Position.FromVSCodePosition(TextEditor.getSelection().start);
let expectedPosition = helper.endPosition;
/*
if (actualPosition.line !== expectedPosition.line ||
actualPosition.character !== expectedPosition.character) {
debugger;
}
*/
assert.equal(actualPosition.line, expectedPosition.line, "Cursor LINE position is wrong.");
assert.equal(actualPosition.character, expectedPosition.character, "Cursor CHARACTER position is wrong.");