Skip to content

Commit

Permalink
Take the count prefix out before trying to remap in ModeHandler.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bruno committed Mar 12, 2017
1 parent 0fc0939 commit b009d41
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,8 @@ export class ModeHandler implements vscode.Disposable {
this._vimState.recordedState.commandList.push(key);

try {
const keys = this._vimState.recordedState.commandList;
// Take the count prefix out to perform the correct remapping.
const keys = this.getCurrentCommandWithoutCountPrefix();
const withinTimeout = now - this._vimState.lastKeyPressedTimestamp < Configuration.timeout;

let handled = false;
Expand Down Expand Up @@ -803,6 +804,21 @@ export class ModeHandler implements vscode.Disposable {
return true;
}

/**
* get the current command without the prefixed count.
* For instance: if the current commandList is ['2', 'h'], returns only ['h'].
*/
private getCurrentCommandWithoutCountPrefix(): string[] {
const commandList = this.vimState.recordedState.commandList;
const firstNonCountCommand = commandList.findIndex(this.isNotCount);

return commandList.slice(firstNonCountCommand);
}

private isNotCount(key: string) {
return isNaN(Number(key));
}

async handleKeyEventHelper(key: string, vimState: VimState): Promise<VimState> {

// Just nope right out of here.
Expand Down

0 comments on commit b009d41

Please sign in to comment.