Fixed gCC

This commit is contained in:
Horace He 2017-05-18 14:25:38 -04:00
parent c5852e5d8c
commit d81d6b84b1
5 changed files with 17 additions and 16 deletions

View File

@ -112,15 +112,6 @@ export class BaseAction {
return true;
}
public doesRepeatedOperatorApply(vimState: VimState, keysPressed: string[]) {
const prevAction = vimState.recordedState.actionsRun[vimState.recordedState.actionsRun.length - 1];
return this.isOperator && keysPressed.length === 1 && prevAction
&& this.modes.indexOf(vimState.currentMode) !== -1
// The previous action is the same as the one we're testing
&& prevAction.constructor === this.constructor
// The key pressed is the same as the previous action's last key.
&& compareKeypressSequence(prevAction.keysPressed.slice(-1), keysPressed);
}
public toString(): string {
return this.keys.join("");
@ -166,12 +157,6 @@ export class Actions {
result.keysPressed = vimState.recordedState.actionKeys.slice(0);
return result;
} else if (action.doesRepeatedOperatorApply(vimState, keysPressed)) {
const result = new type();
result.keysPressed = vimState.recordedState.actionKeys.slice(0);
return result;
}

View File

@ -147,6 +147,8 @@ export abstract class BaseCommand extends BaseAction {
canBeRepeatedWithDot = false;
// mustBeFirstKey = true;
/**
* Run the command a single time.
*/
@ -427,6 +429,7 @@ class CommandEsc extends BaseCommand {
["<C-[>"],
];
mustBeFirstKey = false;
runsOnceForEveryCursor() { return false; }
public async exec(position: Position, vimState: VimState): Promise<VimState> {

View File

@ -23,6 +23,7 @@ class CommandEscInsertMode extends BaseCommand {
["<C-[>"],
];
mustBeFirstKey = false;
runsOnceForEveryCursor() { return false; }
public async exec(position: Position, vimState: VimState): Promise<VimState> {

View File

@ -24,6 +24,9 @@ export class BaseOperator extends BaseAction {
multicursorIndex: number | undefined = undefined;
public doesActionApply(vimState: VimState, keysPressed: string[]): boolean {
if (this.doesRepeatedOperatorApply(vimState, keysPressed)) {
return true;
}
if (this.modes.indexOf(vimState.currentMode) === -1) { return false; }
if (!compareKeypressSequence(this.keys, keysPressed)) { return false; }
if (vimState.recordedState.actionsRun.length > 0 &&
@ -43,6 +46,16 @@ export class BaseOperator extends BaseAction {
return true;
}
public doesRepeatedOperatorApply(vimState: VimState, keysPressed: string[]) {
const prevAction = vimState.recordedState.actionsRun[vimState.recordedState.actionsRun.length - 1];
return this.isOperator && keysPressed.length === 1 && prevAction
&& this.modes.indexOf(vimState.currentMode) !== -1
// The previous action is the same as the one we're testing
&& prevAction.constructor === this.constructor
// The key pressed is the same as the previous action's last key.
&& compareKeypressSequence(prevAction.keysPressed.slice(-1), keysPressed);
}
/**
* Run this operator on a range, returning the new location of the cursor.
*/

View File

@ -680,7 +680,6 @@ export class ModeHandler implements vscode.Disposable {
this._vimState.cursorPosition = newPosition;
this._vimState.cursorStartPosition = newPosition;
this._vimState.desiredColumn = newPosition.character;
// start visual mode?