-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Only align cursor center when it isn't in view. #959
Conversation
This was the original behavior, but it's annoying when you're searching for something offscreen: if I search for a method via Maybe some type of smart behavior would be nice? (center if next match is offscreen, otherwise don't move the screen) |
This way is better. I'll change to it |
40574fb
to
116c516
Compare
Already. |
116c516
to
3b35c0c
Compare
Looks good 👍🏻 Can you update the PR, looks like there's a merge conflict? |
3b35c0c
to
080e62b
Compare
It has rebased master and conflicts are resolved. |
pub fn ensure_cursor_in_view(&mut self, doc: &Document, scrolloff: usize) { | ||
if let Some((row, col)) = self.offset_coords_to_in_view(doc, scrolloff) { | ||
self.offset.row = row; | ||
self.offset.col = col; | ||
} | ||
} | ||
|
||
pub fn is_cursor_in_view(&mut self, doc: &Document, scrolloff: usize) -> bool { | ||
self.offset_coords_to_in_view(doc, scrolloff).is_none() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need to call offset_coords_to_in_view
twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scrolloff is different between two calls.
I don't have idea to merge two calls.
I often use
search
to move cursor to pos I aready know and keep my eyes on it.Currenly helix always align cursor to center that cause Eyes lost the pos.
This PR will only align cursor center when it isn't in view.
Previous:
After: