mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.0174: after paging up and down fold line is wrong
Problem: After paging up and down fold line is wrong.
Solution: Correct the computation of w_topline and w_botline. (Hirohito
Higashi)
907dad72ef
This commit is contained in:
parent
d4e6a75a06
commit
e1fa242a6c
@ -1884,16 +1884,18 @@ int onepage(int dir, long count)
|
||||
}
|
||||
curwin->w_valid &= ~(VALID_WCOL|VALID_WROW|VALID_VIRTCOL);
|
||||
|
||||
/*
|
||||
* Avoid the screen jumping up and down when 'scrolloff' is non-zero.
|
||||
* But make sure we scroll at least one line (happens with mix of long
|
||||
* wrapping lines and non-wrapping line).
|
||||
*/
|
||||
if (retval == OK && dir == FORWARD && check_top_offset()) {
|
||||
scroll_cursor_top(1, false);
|
||||
if (curwin->w_topline <= old_topline
|
||||
&& old_topline < curbuf->b_ml.ml_line_count) {
|
||||
curwin->w_topline = old_topline + 1;
|
||||
if (retval == OK && dir == FORWARD) {
|
||||
// Avoid the screen jumping up and down when 'scrolloff' is non-zero.
|
||||
// But make sure we scroll at least one line (happens with mix of long
|
||||
// wrapping lines and non-wrapping line).
|
||||
if (check_top_offset()) {
|
||||
scroll_cursor_top(1, false);
|
||||
if (curwin->w_topline <= old_topline
|
||||
&& old_topline < curbuf->b_ml.ml_line_count) {
|
||||
curwin->w_topline = old_topline + 1;
|
||||
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
||||
}
|
||||
} else if (curwin->w_botline > curbuf->b_ml.ml_line_count) {
|
||||
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
" Test for folding
|
||||
|
||||
source view_util.vim
|
||||
|
||||
func PrepIndent(arg)
|
||||
return [a:arg] + repeat(["\t".a:arg], 5)
|
||||
endfu
|
||||
@ -648,3 +650,27 @@ func Test_foldtext_recursive()
|
||||
call assert_equal(3, foldclosedend(2))
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
func Test_fold_last_line_with_pagedown()
|
||||
enew!
|
||||
set fdm=manual
|
||||
|
||||
let expect = '+-- 11 lines: 9---'
|
||||
let content = range(1,19)
|
||||
call append(0, content)
|
||||
normal dd9G
|
||||
normal zfG
|
||||
normal zt
|
||||
call assert_equal('9', getline(foldclosed('.')))
|
||||
call assert_equal('19', getline(foldclosedend('.')))
|
||||
call assert_equal(expect, ScreenLines(1, len(expect))[0])
|
||||
call feedkeys("\<C-F>", 'xt')
|
||||
call assert_equal(expect, ScreenLines(1, len(expect))[0])
|
||||
call feedkeys("\<C-F>", 'xt')
|
||||
call assert_equal(expect, ScreenLines(1, len(expect))[0])
|
||||
call feedkeys("\<C-B>\<C-F>\<C-F>", 'xt')
|
||||
call assert_equal(expect, ScreenLines(1, len(expect))[0])
|
||||
|
||||
set fdm&
|
||||
enew!
|
||||
endfunc
|
||||
|
Loading…
Reference in New Issue
Block a user