VIM-1558 Support block inlays in scrolling and motion #173
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.
This PR changes the way scrolling and motion work to take intra-line block inlays, such as Rider's Code Vision. It changes the implementation from being fundamentally line based to being more based on scroll offsets, since the inlays mean that the height of the screen is not constant. When inlays are not displayed, it behaves as though it were still line based.
When inlays are displayed, there are some changes in behaviour:
M
does not follow this behaviour and simply places the current line in the middle of the screenCTRL-D
andCTRL-U
also doesn't follow this rule, instead trying to keep the caret in the same relative screen position (scroll offset, not line number).CTRL-D
orCTRL-U
scrolls half a screen height, which due to inlays isn't a consistent line number. Using[count] CTRL-D
will scroll a consistent number of lines.[count] CTRL-D
is going to be over a screen of scrolling, the scroll distance is capped at a screen height. Inlays are taken into consideration, so the top line is always the bottom line of the previous page + 1.This PR is based on #170, and includes those changes.
Fixes VIM-1558.
Commands tested
The following commands have been manually tested, with and without inlays and with/without
scrolloff
,scrolljump
andscroll
set:CTRL-Y
/CTRL-E
+[count] CTRL-Y
/[count] CTRL-E
CTRL-B
/CTRL-F
+[count] CTRL-B
/[count] CTRL-F
CTRL-D
/CTRL-U
+[count] CTRL-D
/[count] CTRL-U
z<CR>
/zt
+[count] z<CR>
/[count] zt
zz
/z.
+[count] zz
/[count] z.
z-
/zb
+[count] z-
/[count] zb
H
/M
/L
+[count] H
/[count] M
/[count] L
z+
/z^
How to test
gradle runIde
Alternatively, to test in Rider:
gradle.properties
and change the first line to:gradle runIde
Known issues
If the
scrolloff
option is set large enough, and there are block inlays, navigation becomes unpredictable. It works correctly if there are no block inlays. So the technique to set a large scroll offset to force the caret to remain in the centre of the screen is currently incompatible with block inlays.This is because the check to keep the scroll offset to half the screen height is still based on line height and does not include inlay heights, which are different based on the expected location within the file. I'll look at this for a separate PR.