Patch 9.0.0505
Problem: Various problems with 'nosplitscroll'.
Solution: Fix 'nosplitscroll' problems. (Luuk van Baal, closes #11166)
Files: src/globals.h, src/move.c, src/window.c,
src/testdir/test_window_cmd.vim
*** ../vim-9.0.0504/src/globals.h 2022-09-15 12:43:20.476321981 +0100
--- src/globals.h 2022-09-19 16:40:05.935601508 +0100
***************
*** 1742,1744 ****
--- 1742,1748 ----
// Skip win_fix_cursor() call for 'nosplitscroll' when cmdwin is closed.
EXTERN int skip_win_fix_cursor INIT(= FALSE);
#endif
+ // Skip win_fix_scroll() call for 'nosplitscroll' when closing tab page.
+ EXTERN int skip_win_fix_scroll INIT(= FALSE);
+ // Skip update_topline() call while executing win_fix_scroll().
+ EXTERN int skip_update_topline INIT(= FALSE);
*** ../vim-9.0.0504/src/move.c 2022-09-16 20:50:44.968907925 +0100
--- src/move.c 2022-09-19 16:40:05.935601508 +0100
***************
*** 991,997 ****
/*
* First make sure that w_topline is valid (after moving the cursor).
*/
! if (p_spsc)
update_topline();
/*
--- 991,997 ----
/*
* First make sure that w_topline is valid (after moving the cursor).
*/
! if (!skip_update_topline)
update_topline();
/*
*** ../vim-9.0.0504/src/window.c 2022-09-17 16:16:31.921060718 +0100
--- src/window.c 2022-09-19 16:40:05.935601508 +0100
***************
*** 4478,4483 ****
--- 4478,4484 ----
// Don't repeat a message in another tab page.
set_keep_msg(NULL, 0);
+ skip_win_fix_scroll = TRUE;
if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer,
trigger_leave_autocmds) == OK)
{
***************
*** 4488,4493 ****
--- 4489,4495 ----
enter_tabpage(curtab, curbuf, trigger_enter_autocmds,
trigger_leave_autocmds);
}
+ skip_win_fix_scroll = FALSE;
}
/*
***************
*** 5481,5487 ****
compute_cmdrow();
curtab->tp_ch_used = p_ch;
! if (!p_spsc)
win_fix_scroll(TRUE);
#if 0
--- 5483,5489 ----
compute_cmdrow();
curtab->tp_ch_used = p_ch;
! if (!p_spsc && !skip_win_fix_scroll)
win_fix_scroll(TRUE);
#if 0
***************
*** 6362,6371 ****
win_T *wp;
linenr_T lnum;
FOR_ALL_WINDOWS(wp)
{
! // Skip when window height has not changed or when
! // buffer has less lines than the window height.
if (wp->w_height != wp->w_prev_height)
{
// Determine botline needed to avoid scrolling and set cursor.
--- 6364,6373 ----
win_T *wp;
linenr_T lnum;
+ skip_update_topline = TRUE; // avoid scrolling in curs_rows()
FOR_ALL_WINDOWS(wp)
{
! // Skip when window height has not changed.
if (wp->w_height != wp->w_prev_height)
{
// Determine botline needed to avoid scrolling and set cursor.
***************
*** 6387,6394 ****
wp->w_prev_height = wp->w_height;
wp->w_prev_winrow = wp->w_winrow;
}
// Ensure cursor is valid when not in normal mode or when resized.
! if (!(get_real_state() & (MODE_NORMAL|MODE_CMDLINE)))
win_fix_cursor(FALSE);
else if (resize)
win_fix_cursor(TRUE);
--- 6389,6397 ----
wp->w_prev_height = wp->w_height;
wp->w_prev_winrow = wp->w_winrow;
}
+ skip_update_topline = FALSE;
// Ensure cursor is valid when not in normal mode or when resized.
! if (!(get_real_state() & (MODE_NORMAL|MODE_CMDLINE|MODE_TERMINAL)))
win_fix_cursor(FALSE);
else if (resize)
win_fix_cursor(TRUE);
***************
*** 6435,6445 ****
else
{ // Ensure cursor stays visible if we are not in normal mode.
wp->w_fraction = 0.5 * FRACTION_MULT;
- // Make sure cursor is closer to topline than botline.
- if (so == wp->w_height / 2
- && nlnum - wp->w_topline > wp->w_botline - 1 - nlnum)
- wp->w_fraction++;
scroll_to_fraction(wp, wp->w_prev_height);
}
}
}
--- 6438,6445 ----
else
{ // Ensure cursor stays visible if we are not in normal mode.
wp->w_fraction = 0.5 * FRACTION_MULT;
scroll_to_fraction(wp, wp->w_prev_height);
+ validate_botline_win(curwin);
}
}
}
*** ../vim-9.0.0504/src/testdir/test_window_cmd.vim 2022-09-17 16:16:31.921060718 +0100
--- src/testdir/test_window_cmd.vim 2022-09-19 16:40:05.935601508 +0100
***************
*** 1631,1640 ****
set laststatus&
endfunc
! " Ensure no scrolling happens with 'nosplitscroll' with and without a
! " winbar, tabline, for each possible value of 'laststatus', 'scrolloff',
" 'equalalways', and regardless of the cursor position.
! func Test_splitscroll_with_splits()
set nowrap
set nosplitscroll
--- 1631,1641 ----
set laststatus&
endfunc
! " Ensure no scrolling happens with 'nosplitscroll' for a sequence of
! " split operations for various options: with and without a winbar,
! " tabline, for each possible value of 'laststatus', 'scrolloff',
" 'equalalways', and regardless of the cursor position.
! func Test_nosplitscroll_options()
set nowrap
set nosplitscroll
***************
*** 1648,1654 ****
tabnew | tabonly! | redraw
let tabline = (gui ? 0 : ((run % 5) ? 1 : 0))
let winbar_sb = (run % 2) && (run % 3)
! execute 'set scrolloff=' . !(run % 3) ? 0 : run
execute 'set laststatus=' . (run % 3)
execute 'set ' . ((run % 2) ? 'equalalways' : 'noequalalways')
execute 'set ' . ((run % 3) ? 'splitbelow' : 'nosplitbelow')
--- 1649,1655 ----
tabnew | tabonly! | redraw
let tabline = (gui ? 0 : ((run % 5) ? 1 : 0))
let winbar_sb = (run % 2) && (run % 3)
! execute 'set scrolloff=' . (!(run % 4) ? 0 : run)
execute 'set laststatus=' . (run % 3)
execute 'set ' . ((run % 2) ? 'equalalways' : 'noequalalways')
execute 'set ' . ((run % 3) ? 'splitbelow' : 'nosplitbelow')
***************
*** 1790,1820 ****
set splitscroll&
endfunction
! " No scroll when aucmd_win is opened.
! function Test_nosplitscroll_aucmdwin()
set nosplitscroll
call setline(1, range(1, &lines))
norm Gzz
let top = line('w0')
call setbufvar(bufnr("test", 1) , '&buftype', 'nofile')
call assert_equal(top, line('w0'))
!
! %bwipeout!
! set splitscroll&
! endfunc
!
! " No scroll when help is closed and buffer line count < window height.
! function Test_nosplitscroll_helpwin()
! set nosplitscroll
! set splitbelow
!
! call setline(1, range(&lines - 10))
norm G
let top = line('w0')
help | quit
call assert_equal(top, line('w0'))
set splitbelow&
set splitscroll&
endfunc
--- 1791,1818 ----
set splitscroll&
endfunction
! function Test_nosplitscroll_misc()
set nosplitscroll
+ set splitbelow
call setline(1, range(1, &lines))
norm Gzz
let top = line('w0')
+ " No scroll when aucmd_win is opened
call setbufvar(bufnr("test", 1) , '&buftype', 'nofile')
call assert_equal(top, line('w0'))
! " No scroll when tab is changed/closed
! tab help | close
! call assert_equal(top, line('w0'))
! " No scroll when help is closed and buffer line count < window height
! norm ggdG
! call setline(1, range(1, &lines - 10))
norm G
let top = line('w0')
help | quit
call assert_equal(top, line('w0'))
+ %bwipeout!
set splitbelow&
set splitscroll&
endfunc
*** ../vim-9.0.0504/src/version.c 2022-09-19 16:08:01.428998441 +0100
--- src/version.c 2022-09-19 16:41:54.475093249 +0100
***************
*** 701,702 ****
--- 701,704 ----
{ /* Add new patch number below this line */
+ /**/
+ 505,
/**/
--
From "know your smileys":
:-* A big kiss!
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///