private _findMapping()

in vim-sample/src/controller.ts [221:288]


	private _findMapping(input: string, editor: TextEditor, modifierKeys: ModifierKeys): ITypeResult {
		const command = Mappings.findCommand(input, modifierKeys);
		if (command) {
			this._currentInput = '';
			return {
				hasConsumedInput: true,
				executeEditorCommand: command
			};
		}

		const operator = Mappings.findOperator(input, modifierKeys);
		if (operator) {
			if (this._isVisual) {
				if (operator.runVisual(this, editor)) {
					this._currentInput = '';
				}
			} else {
				// Mode.NORMAL
				if (operator.runNormal(this, editor)) {
					this._currentInput = '';
				}
			}
			return {
				hasConsumedInput: true,
				executeEditorCommand: null
			};
		}

		const motionCommand = Mappings.findMotionCommand(input, this._isVisual, modifierKeys);
		if (motionCommand) {
			this._currentInput = '';
			return {
				hasConsumedInput: true,
				executeEditorCommand: motionCommand
			};
		}

		const motion = Mappings.findMotion(input);
		if (motion) {
			const newPos = motion.run(editor.document, editor.selection.active, this._motionState);
			if (this._isVisual) {
				setSelectionAndReveal(editor, this._motionState.anchor, newPos.line, newPos.character);
			} else {
				// Mode.NORMAL
				setPositionAndReveal(editor, newPos.line, newPos.character);
			}
			this._currentInput = '';
			return {
				hasConsumedInput: true,
				executeEditorCommand: null
			};
		}

		// is it motion building
		if (this.isMotionPrefix(input)) {
			return {
				hasConsumedInput: true,
				executeEditorCommand: null
			};
		}

		// INVALID INPUT - beep!!
		this._currentInput = '';
		return {
			hasConsumedInput: true,
			executeEditorCommand: null
		};
	}