Add support for moving to a specific line #1196
Merged
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.
Fixes #240
Fixes #1033
I know there's been a few attempts in the past to implement this, such as #242 and #1040 and possibly others that I have missed. I'm not sure why those attempts appear to have been stalled, I suppose although setting
dir.ind
is straightforward, the difficult part is determining how to calculatedir.pos
so that the amount of scrolling is minimised.It looks possible to simply use the existing
up
/down
functions to move to a new line (no scrolling happens if the destination is already visible, so the effect is smoother). This is already used in other functions likefindNext
/findPrev
andsearchNext
/searchPrev
, and I think it's better to recycle the scrolling logic in theup
/down
functions rather write it from scratch.