Support scroll commands

This commit is contained in:
Sandeep Somavarapu
2016-08-04 18:08:09 +02:00
parent d7a60b2c70
commit 0b31fec3d8
6 changed files with 176 additions and 75 deletions

View File

@ -16,7 +16,7 @@ import {
import {Words} from './words';
import {MotionState, Motion} from './motions';
import {Mode, IController, DeleteRegister, Command} from './common';
import {Mode, IController, DeleteRegister, Command, ModifierKeys} from './common';
import {Mappings} from './mappings';
export interface ITypeResult {
@ -139,7 +139,7 @@ export class Controller implements IController {
return `VIM:> ${label}` + (this._currentInput ? ` >${this._currentInput}` : ``);
}
public type(editor: TextEditor, text: string): Thenable<ITypeResult> {
public type(editor: TextEditor, text: string, modifierKeys: ModifierKeys): Thenable<ITypeResult> {
if (this._currentMode !== Mode.NORMAL && this._currentMode !== Mode.REPLACE) {
return Promise.resolve({
hasConsumedInput: false,
@ -160,7 +160,7 @@ export class Controller implements IController {
});
}
this._currentInput += text;
return this._interpretNormalModeInput(editor);
return this._interpretNormalModeInput(editor, modifierKeys);
}
public replacePrevChar(editor: TextEditor, text: string, replaceCharCnt: number): boolean {
@ -179,19 +179,19 @@ export class Controller implements IController {
return true;
}
private _interpretNormalModeInput(editor: TextEditor): Thenable<ITypeResult> {
private _interpretNormalModeInput(editor: TextEditor, modifierKeys: ModifierKeys): Thenable<ITypeResult> {
if (this._currentInput.startsWith(':')) {
return vscode.window.showInputBox({value: 'tabm'}).then((value) => {
let result = this._findMapping(value || '', editor);
let result = this._findMapping(value || '', editor, modifierKeys);
return Promise.resolve(result);
});
}
let result = this._findMapping(this._currentInput, editor);
let result = this._findMapping(this._currentInput, editor, modifierKeys);
return Promise.resolve(result);
}
private _findMapping(input: string, editor: TextEditor): ITypeResult {
let command = Mappings.findCommand(input);
private _findMapping(input: string, editor: TextEditor, modifierKeys: ModifierKeys): ITypeResult {
let command = Mappings.findCommand(input, modifierKeys);
if (command) {
this._currentInput = '';
return {
@ -200,7 +200,7 @@ export class Controller implements IController {
};
}
let operator = Mappings.findOperator(input);
let operator = Mappings.findOperator(input, modifierKeys);
if (operator) {
if (this._isVisual) {
if (operator.runVisual(this, editor)) {
@ -218,7 +218,7 @@ export class Controller implements IController {
};
}
let motionCommand = Mappings.findMotionCommand(input, this._isVisual);
let motionCommand = Mappings.findMotionCommand(input, this._isVisual, modifierKeys);
if (motionCommand) {
this._currentInput = '';
return {