Describe the bug
A couple of examples of the situation described in the title:
/ 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:
x in a file with ma.x is outside of the viewport.'a.Expected behavior
The cursor line x should be vertically centered.
Screenshots

Environment (please complete the following information):
Checking if there's an update or a workaround for this bug. For example, a keybinding that might center the screen after the search.
Looks like zz is the binding I was looking for :)
Still would be nice if the cursor was centered by default after the search.
@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.
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
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).
@pnalchajian Please file a separate issue
Same issue that @pnalchajian mentioned. Not sure if he has created a new issue for this or not.
Most helpful comment
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).