mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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'.
58448e09be
This commit is contained in:
parent
7a03cd1dba
commit
e1a81c8d8b
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user