Fix cursor may move too many lines over "right" & "below" virt text #14317
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.
Based on #14307, see dylanahsmith/vim@fix-12213...dylanahsmith:vim:fix-cursor-move-over-below-right to exclude that branch's commits from the comparison
Problem
The problem can be demonstrated by saving the following vim script as repro.vim, then loading it with
vim --clean -S repro.vim
which without this fix results in the cursor appearing on the screen line below the last character in
second line
.My PR #14307 actually work around this issue that I originally uncovered from an earlier version of its regression test, which added the "right" virtual text property before the "below" property. As noted in that PR description, those text properties aren't sorted, but instead got stored in the reverse order of how they were stored.
When calculating the line height in
prop_count_above_below
,next_right_goes_below = TRUE
was for some reason set when encountering the "below" text property, leading to it incorrectly counting an "extra" line for the following "right" property even though it was the first "right" property.Solution
Only "right" virtual text properties should always shift other "right" properties on the same line to the next line, so I removed the unnecessary
next_right_goes_below = TRUE;
statements and simplified the code. I then updated the regression test to cover this case, such that the test fails without this fix.