Skip to content

Commit

Permalink
Merge pull request #261 from VSCodeVim/scroll-to-center
Browse files Browse the repository at this point in the history
Add zz.
  • Loading branch information
johnfn committed Jun 9, 2016
2 parents 0a292b5 + b385dbc commit 04b08bf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
vimState.commandAction = VimCommandActions.ScrollCursorToCenter;

return vimState;
}
}

@RegisterAction
class CommandUnfold extends BaseCommand {
modes = [ModeName.Normal];
Expand Down
6 changes: 5 additions & 1 deletion src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export enum VimCommandActions {
MoveFullPageDown,
MoveFullPageUp,
Dot,
ScrollCursorToCenter
}

/**
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 04b08bf

Please sign in to comment.