fix(move): consume skipcol before revealing filler lines (#34143)

Problem:  When scrolling (the text) down with 'smoothscroll', filler
          lines are revealed before the text skipped with `w_skipcol`.
Solution: Check `w_skipcol` before filler lines.
This commit is contained in:
luukvbaal
2025-05-24 00:45:00 +02:00
committed by GitHub
parent 071dcab68f
commit 6ce2877327
2 changed files with 69 additions and 43 deletions

View File

@ -1335,13 +1335,10 @@ bool scrolldown(win_T *wp, linenr_T line_count, int byfold)
hasFolding(wp, wp->w_topline, &wp->w_topline, NULL);
validate_cursor(wp); // w_wrow needs to be valid
for (int todo = line_count; todo > 0; todo--) {
if (wp->w_topfill < win_get_fill(wp, wp->w_topline)
&& wp->w_topfill < wp->w_view_height - 1) {
wp->w_topfill++;
done++;
} else {
bool can_fill = wp->w_topfill < wp->w_view_height - 1
&& wp->w_topfill < win_get_fill(wp, wp->w_topline);
// break when at the very top
if (wp->w_topline == 1 && (!do_sms || wp->w_skipcol < width1)) {
if (wp->w_topline == 1 && !can_fill && (!do_sms || wp->w_skipcol < width1)) {
break;
}
if (do_sms && wp->w_skipcol >= width1) {
@ -1353,6 +1350,9 @@ bool scrolldown(win_T *wp, linenr_T line_count, int byfold)
}
redraw_later(wp, UPD_NOT_VALID);
done++;
} else if (can_fill) {
wp->w_topfill++;
done++;
} else {
// scroll a text line down
wp->w_topline--;
@ -1387,7 +1387,6 @@ bool scrolldown(win_T *wp, linenr_T line_count, int byfold)
}
}
}
}
wp->w_botline--; // approximate w_botline
invalidate_botline(wp);
}

View File

@ -6677,6 +6677,33 @@ if (h->n_buckets < new_n_buckets) { // expand
]],
})
end)
it("not revealed before skipcol scrolling up with 'smoothscroll'", function()
api.nvim_set_option_value('smoothscroll', true, {})
api.nvim_buf_set_lines(0, 0, -1, false, { ('x'):rep(screen._width * 2) })
api.nvim_buf_set_extmark(0, ns, 0, 0, { virt_lines_above = true, virt_lines = { { { 'VIRT1' } } } } )
feed('<C-E>')
screen:expect([[
{1:<<<}xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^x|
{1:~ }|*10
|
]])
feed('<C-Y>')
screen:expect([[
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^x|
{1:~ }|*9
|
]])
feed('<C-Y>')
screen:expect([[
VIRT1 |
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx^x|
{1:~ }|*8
|
]])
end)
end)
describe('decorations: signs', function()