From b385dbcc0fc1b8a1550a1bc4473c262432d02fb5 Mon Sep 17 00:00:00 2001 From: johnfn Date: Thu, 9 Jun 2016 00:17:27 -0700 Subject: [PATCH] Add zz. --- src/actions/actions.ts | 12 ++++++++++++ src/mode/modeHandler.ts | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/actions/actions.ts b/src/actions/actions.ts index 2ef28ee1189..614e6dbd8db 100644 --- a/src/actions/actions.ts +++ b/src/actions/actions.ts @@ -394,6 +394,18 @@ class CommandFold extends BaseCommand { } } +@RegisterAction +class CommandCenterScroll extends BaseCommand { + modes = [ModeName.Normal]; + keys = ["z", "z"]; + + public async exec(position: Position, vimState: VimState): Promise { + vimState.commandAction = VimCommandActions.ScrollCursorToCenter; + + return vimState; + } +} + @RegisterAction class CommandUnfold extends BaseCommand { modes = [ModeName.Normal]; diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index 6b3f58ebf0f..2fcfb927e7b 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -29,6 +29,7 @@ export enum VimCommandActions { MoveFullPageDown, MoveFullPageUp, Dot, + ScrollCursorToCenter } /** @@ -398,7 +399,6 @@ export class ModeHandler implements vscode.Disposable { vscode.window.activeTextEditor.revealRange(new vscode.Range(vimState.cursorPosition, vimState.cursorPosition)); - // Reset state vimState.actionState = new ActionState(vimState); @@ -465,6 +465,10 @@ export class ModeHandler implements vscode.Disposable { case VimCommandActions.Redo: await vscode.commands.executeCommand("redo"); break; case VimCommandActions.MoveFullPageDown: await vscode.commands.executeCommand("cursorPageUp"); break; case VimCommandActions.MoveFullPageUp: await vscode.commands.executeCommand("cursorPageDown"); break; + case VimCommandActions.ScrollCursorToCenter: + vscode.window.activeTextEditor.revealRange(new vscode.Range(vimState.cursorPosition, vimState.cursorPosition), + vscode.TextEditorRevealType.InCenter); + break; case VimCommandActions.Dot: const oldDotKeysCopy = vimState.previousFullAction.slice(0);