Improve buffer view relocation after jumping to a far-away location #2628
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the cursor is moved to a location which is far away (e.g. after a search, a goto line, or when opening a file at a given line), the view is always relocated in such a way that the cursor is at the bottom or at the top (minus scrollmargin), i.e. as if we just scrolled to this location. It's not like in other editors, and IMHO it's annoying. When we jump to a new location far away, we usually want to see more of its context, so the cursor should be placed closer to the center of the view, not near its edges. Certainly not near the bottom.
So this PR implements the behavior similar to other editors:
Similarly, when opening a file at a given location, if this location is less than one frame away from the beginning of the file, then keep the current behavior, otherwise this initial location is placed at 25% of the window height.
As a bonus, this PR also fixes issue #1800:
onBufPaneOpen
lua callback called prematurely when the bufpane is not fully initialized yet.Fixes #1790
Fixes #1800