Skip to content

Commit

Permalink
Center cursor vertically when appropriate
Browse files Browse the repository at this point in the history
When an action causes the cursor to move outside of the viewport, center
it vertically in order to better mimic Vim's behavior.

Fixes VSCodeVim#2960
  • Loading branch information
hhu94 committed Aug 16, 2018
1 parent 80aa2fb commit b7d4466
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,12 @@ export class ModeHandler implements vscode.Disposable {

vimState.allCursors = resultingList;

// If the cursor moved out of the viewport, center it vertically
vimState.editor.revealRange(
new vscode.Range(vimState.cursorPosition, vimState.cursorPosition),
vscode.TextEditorRevealType.InCenterIfOutsideViewport
);

return vimState;
}

Expand Down

0 comments on commit b7d4466

Please sign in to comment.