diff options
author | luukvbaal <luukvbaal@gmail.com> | 2025-03-27 12:51:57 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-27 12:51:57 +0100 |
commit | ce0c0c31a08975dd2e34207afb1a2cd544775bad (patch) | |
tree | 1a2862e5bb1777d192fd0128570f19f3e70e1d88 /src | |
parent | c5044bd021482c4bdcb7d2e3ff5b0e688daa681b (diff) | |
download | rneovim-ce0c0c31a08975dd2e34207afb1a2cd544775bad.tar.gz rneovim-ce0c0c31a08975dd2e34207afb1a2cd544775bad.tar.bz2 rneovim-ce0c0c31a08975dd2e34207afb1a2cd544775bad.zip |
fix(display): scroll logic does not take into account concealed topline (#33054)
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/drawscreen.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/nvim/drawscreen.c b/src/nvim/drawscreen.c index 4c1b756ea1..2905d51657 100644 --- a/src/nvim/drawscreen.c +++ b/src/nvim/drawscreen.c @@ -1700,6 +1700,16 @@ static void win_update(win_T *wp) } } + // Below logic compares wp->w_topline against wp->w_lines[0].wl_lnum, + // which may point to a line below wp->w_topline if it is concealed; + // incurring scrolling even though wp->w_topline is still the same. + // Compare against an adjusted topline instead: + linenr_T topline_conceal = wp->w_topline; + while (decor_conceal_line(wp, topline_conceal - 1, false)) { + topline_conceal++; + hasFolding(wp, topline_conceal, NULL, &topline_conceal); + } + // If there are no changes on the screen that require a complete redraw, // handle three cases: // 1: we are off the top of the screen by a few lines: scroll down @@ -1712,12 +1722,12 @@ static void win_update(win_T *wp) if (mod_top != 0 && wp->w_topline == mod_top && (!wp->w_lines[0].wl_valid - || wp->w_topline == wp->w_lines[0].wl_lnum)) { + || topline_conceal == wp->w_lines[0].wl_lnum)) { // w_topline is the first changed line and window is not scrolled, // the scrolling from changed lines will be done further down. } else if (wp->w_lines[0].wl_valid - && (wp->w_topline < wp->w_lines[0].wl_lnum - || (wp->w_topline == wp->w_lines[0].wl_lnum + && (topline_conceal < wp->w_lines[0].wl_lnum + || (topline_conceal == wp->w_lines[0].wl_lnum && wp->w_topfill > wp->w_old_topfill))) { // New topline is above old topline: May scroll down. int j; |