neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit e1a81c8d8bbbe67710980f0e81aa9473e37defee
parent 7a03cd1dba0eeac361a518ee5d92ff81405c3690
Author: luukvbaal <luukvbaal@gmail.com>
Date:   Sat, 11 May 2024 12:17:57 +0200

vim-patch:9.1.0407: Stuck with long line and half-page scrolling (#28704)

Problem:  No scrolling happens with half-page scrolling with line
          filling entire window when 'smoothscroll' is disabled.
          (Mathias Rav, after v9.1.0285)
Solution: Adjust amount to move cursor by so that it is moved the same
          number of lines as was scrolled, even when scrolling different
          number of lines than requested with 'nosmoothscroll'.

https://github.com/vim/vim/commit/58448e09be497a8abb595ae309b6edfbc8e0e05a
Diffstat:
Msrc/nvim/move.c | 11+++++++----
Mtest/old/testdir/test_normal.vim | 8++++++++
2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/nvim/move.c b/src/nvim/move.c @@ -2412,8 +2412,10 @@ static int get_scroll_overlap(Direction dir) } } -/// Scroll "count" lines with 'smoothscroll' in direction "dir". -static bool scroll_with_sms(Direction dir, int count) +/// Scroll "count" lines with 'smoothscroll' in direction "dir". Return true +/// when scrolling happened. Adjust "curscount" for scrolling different amount +/// of lines when 'smoothscroll' is disabled. +static bool scroll_with_sms(Direction dir, int count, int *curscount) { int prev_sms = curwin->w_p_sms; colnr_T prev_skipcol = curwin->w_skipcol; @@ -2435,6 +2437,7 @@ static bool scroll_with_sms(Direction dir, int count) while (curwin->w_skipcol > 0 && curwin->w_topline < curbuf->b_ml.ml_line_count) { scroll_redraw(fixdir == FORWARD, 1); + *curscount += (fixdir == dir ? 1 : -1); } } curwin->w_p_sms = prev_sms; @@ -2482,7 +2485,7 @@ int pagescroll(Direction dir, int count, bool half) // (Try to) scroll the window unless already at the end of the buffer. if (count > 0) { - nochange = scroll_with_sms(dir, count); + nochange = scroll_with_sms(dir, count, &curscount); curwin->w_cursor.lnum = prev_lnum; curwin->w_cursor.col = prev_col; curwin->w_curswant = prev_curswant; @@ -2500,7 +2503,7 @@ int pagescroll(Direction dir, int count, bool half) // Scroll [count] times 'window' or current window height lines. count *= ((ONE_WINDOW && p_window > 0 && p_window < Rows - 1) ? MAX(1, (int)p_window - 2) : get_scroll_overlap(dir)); - nochange = scroll_with_sms(dir, count); + nochange = scroll_with_sms(dir, count, &count); // Place cursor at top or bottom of window. validate_botline(curwin); diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim @@ -4270,4 +4270,12 @@ func Test_page_cursor_topbot() bwipe! endfunc +" Test for Ctrl-D with long line +func Test_halfpage_longline() + 10new + call setline(1, ['long'->repeat(1000), 'short']) + exe "norm! \<C-D>" + call assert_equal(2, line('.')) + bwipe! +endfunc " vim: shiftwidth=2 sts=2 expandtab nofoldenable