fix(helix-term): ensure cursor is in view after LSP jump commands #14795
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.
Currently, following a jump command from the language server (e.g.,
goto_definition), the view scrolls vertically to reveal the definition but not horizontally. This often results in the newly highlighted definition being offscreen (specifically on vertical monitors), resulting in a confusing user experience.This pull request fixes this by invoking
view.ensure_cursor_in_view()at the end ofjump_to_position()inhelix-term/src/commands/lsp.rs. Please don't hesitate to suggest a better way of achieving this if there is one (which is likely.) My gut tells me bothalign_view()andensure_cursor_in_view()do not both need to be invoked, but removing the former resulted in buggy behavior when I tested it.For regular (synchronous) commands, such as
rotate_selections_forward(mapped to)), the view is scrolled horizontally to reveal the primary cursor becauseview.ensure_cursor_in_view()is invoked following all command execution (currently line 1481 ofhelix-term/src/ui/editor.rs).Before:

After:
