Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moving the cursor to somewhere outside of the viewport should center the cursor vertically #2960

Closed
hhu94 opened this issue Aug 15, 2018 · 7 comments · Fixed by #2962 or #4434
Closed
Assignees
Labels

Comments

@hhu94
Copy link
Contributor

hhu94 commented Aug 15, 2018

Describe the bug
A couple of examples of the situation described in the title:

  • When jumping to a mark outside of the viewport, the cursor line is placed at either the first or second from last line in the viewport.
  • When searching for a string with / and the next occurrence is outside of the viewport, the cursor line is placed at either the first or second from last line in the viewport.

To Reproduce
Steps to reproduce the behavior:

  1. Set a mark at line x in a file with ma.
  2. Navigate to another part of the file such that the line x is outside of the viewport.
  3. Jump to the mark with 'a.

Expected behavior
The cursor line x should be vertically centered.

Screenshots
marks

Environment (please complete the following information):

  • Extension (VsCodeVim) version: 0.16.0
  • VSCode version: 1.25.1
  • OS: Windows 10
@hhu94 hhu94 changed the title Jumping to a mark doesn't center the cursor line Moving the cursor to somewhere outside of the viewport should center the cursor vertically Aug 16, 2018
hhu94 added a commit to hhu94/Vim that referenced this issue Aug 16, 2018
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
hhu94 added a commit to hhu94/Vim that referenced this issue Aug 16, 2018
When the cursor is moved to outside of the viewport, center it vertically
in order to better mimic Vim's behavior.

Fixes VSCodeVim#2960
@jpoon jpoon added the kind/bug label Aug 25, 2018
@jpoon jpoon reopened this Sep 7, 2018
@naseer
Copy link

naseer commented Jul 31, 2019

Checking if there's an update or a workaround for this bug. For example, a keybinding that might center the screen after the search.

@naseer
Copy link

naseer commented Jul 31, 2019

Looks like zz is the binding I was looking for :)
Still would be nice if the cursor was centered by default after the search.

@jwmann
Copy link

jwmann commented Aug 1, 2019

@naseer I'm not sure what zz is supposed to do but in Vim the M key will move the cursor to the vertical middle of the screen.

EDIT:
Seems like zz is more inline with what you were talking about. Centering the word at the middle, not just the cursor.

@J-Fields J-Fields self-assigned this Dec 29, 2019
@J-Fields
Copy link
Member

J-Fields commented Dec 29, 2019

Digging into this a bit more. In vim, if you put the cursor at the top of the viewport with H (scrolloff=0), 14k does not center the viewport around the new cursor position, but 15k does.
It takes 18j at the bottom to center, but I think that's because of the status line, etc.

Seems going to marks behaves the same way. I think we should center if the cursor is 15 or more lines outside the viewport, which should also prevent issues such as #2998

@pnalchajian
Copy link

The above commit (4434) seems to behave unexpectedly around heavily folded code. If I'm traversing lines (simple cursor movements like jk) in a non-folded section of code, the cursor works just fine. When I'm doing the same amidst many folds, cursor navigation behaves almost like a scrollOffset is set (keeping the cursor in the center always).

@J-Fields
Copy link
Member

J-Fields commented Mar 1, 2020

@pnalchajian Please file a separate issue

@0xhmn
Copy link

0xhmn commented Mar 8, 2020

Same issue that @pnalchajian mentioned. Not sure if he has created a new issue for this or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment