forked from aniani/vim
patch 9.0.0505: various problems with 'nosplitscroll'
Problem: Various problems with 'nosplitscroll'. Solution: Fix 'nosplitscroll' problems. (Luuk van Baal, closes #11166)
This commit is contained in:
committed by
Bram Moolenaar
parent
c9e4a6f191
commit
faf1d412f5
@@ -1742,3 +1742,7 @@ EXTERN optmagic_T magic_overruled INIT(= OPTION_MAGIC_NOT_SET);
|
|||||||
// Skip win_fix_cursor() call for 'nosplitscroll' when cmdwin is closed.
|
// Skip win_fix_cursor() call for 'nosplitscroll' when cmdwin is closed.
|
||||||
EXTERN int skip_win_fix_cursor INIT(= FALSE);
|
EXTERN int skip_win_fix_cursor INIT(= FALSE);
|
||||||
#endif
|
#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);
|
||||||
|
@@ -991,7 +991,7 @@ curs_columns(
|
|||||||
/*
|
/*
|
||||||
* First make sure that w_topline is valid (after moving the cursor).
|
* First make sure that w_topline is valid (after moving the cursor).
|
||||||
*/
|
*/
|
||||||
if (p_spsc)
|
if (!skip_update_topline)
|
||||||
update_topline();
|
update_topline();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -1631,10 +1631,11 @@ func Test_win_equal_last_status()
|
|||||||
set laststatus&
|
set laststatus&
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Ensure no scrolling happens with 'nosplitscroll' with and without a
|
" Ensure no scrolling happens with 'nosplitscroll' for a sequence of
|
||||||
" winbar, tabline, for each possible value of 'laststatus', 'scrolloff',
|
" 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.
|
" 'equalalways', and regardless of the cursor position.
|
||||||
func Test_splitscroll_with_splits()
|
func Test_nosplitscroll_options()
|
||||||
set nowrap
|
set nowrap
|
||||||
set nosplitscroll
|
set nosplitscroll
|
||||||
|
|
||||||
@@ -1648,7 +1649,7 @@ func Test_splitscroll_with_splits()
|
|||||||
tabnew | tabonly! | redraw
|
tabnew | tabonly! | redraw
|
||||||
let tabline = (gui ? 0 : ((run % 5) ? 1 : 0))
|
let tabline = (gui ? 0 : ((run % 5) ? 1 : 0))
|
||||||
let winbar_sb = (run % 2) && (run % 3)
|
let winbar_sb = (run % 2) && (run % 3)
|
||||||
execute 'set scrolloff=' . !(run % 3) ? 0 : run
|
execute 'set scrolloff=' . (!(run % 4) ? 0 : run)
|
||||||
execute 'set laststatus=' . (run % 3)
|
execute 'set laststatus=' . (run % 3)
|
||||||
execute 'set ' . ((run % 2) ? 'equalalways' : 'noequalalways')
|
execute 'set ' . ((run % 2) ? 'equalalways' : 'noequalalways')
|
||||||
execute 'set ' . ((run % 3) ? 'splitbelow' : 'nosplitbelow')
|
execute 'set ' . ((run % 3) ? 'splitbelow' : 'nosplitbelow')
|
||||||
@@ -1790,31 +1791,28 @@ function Test_nosplitscroll_cmdwin_cursor_position()
|
|||||||
set splitscroll&
|
set splitscroll&
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" No scroll when aucmd_win is opened.
|
function Test_nosplitscroll_misc()
|
||||||
function Test_nosplitscroll_aucmdwin()
|
|
||||||
set nosplitscroll
|
set nosplitscroll
|
||||||
|
set splitbelow
|
||||||
|
|
||||||
call setline(1, range(1, &lines))
|
call setline(1, range(1, &lines))
|
||||||
norm Gzz
|
norm Gzz
|
||||||
let top = line('w0')
|
let top = line('w0')
|
||||||
|
" No scroll when aucmd_win is opened
|
||||||
call setbufvar(bufnr("test", 1) , '&buftype', 'nofile')
|
call setbufvar(bufnr("test", 1) , '&buftype', 'nofile')
|
||||||
call assert_equal(top, line('w0'))
|
call assert_equal(top, line('w0'))
|
||||||
|
" No scroll when tab is changed/closed
|
||||||
%bwipeout!
|
tab help | close
|
||||||
set splitscroll&
|
call assert_equal(top, line('w0'))
|
||||||
endfunc
|
" No scroll when help is closed and buffer line count < window height
|
||||||
|
norm ggdG
|
||||||
" No scroll when help is closed and buffer line count < window height.
|
call setline(1, range(1, &lines - 10))
|
||||||
function Test_nosplitscroll_helpwin()
|
|
||||||
set nosplitscroll
|
|
||||||
set splitbelow
|
|
||||||
|
|
||||||
call setline(1, range(&lines - 10))
|
|
||||||
norm G
|
norm G
|
||||||
let top = line('w0')
|
let top = line('w0')
|
||||||
help | quit
|
help | quit
|
||||||
call assert_equal(top, line('w0'))
|
call assert_equal(top, line('w0'))
|
||||||
|
|
||||||
|
%bwipeout!
|
||||||
set splitbelow&
|
set splitbelow&
|
||||||
set splitscroll&
|
set splitscroll&
|
||||||
endfunc
|
endfunc
|
||||||
|
@@ -699,6 +699,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
505,
|
||||||
/**/
|
/**/
|
||||||
504,
|
504,
|
||||||
/**/
|
/**/
|
||||||
|
16
src/window.c
16
src/window.c
@@ -4478,6 +4478,7 @@ goto_tabpage_tp(
|
|||||||
// Don't repeat a message in another tab page.
|
// Don't repeat a message in another tab page.
|
||||||
set_keep_msg(NULL, 0);
|
set_keep_msg(NULL, 0);
|
||||||
|
|
||||||
|
skip_win_fix_scroll = TRUE;
|
||||||
if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer,
|
if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer,
|
||||||
trigger_leave_autocmds) == OK)
|
trigger_leave_autocmds) == OK)
|
||||||
{
|
{
|
||||||
@@ -4488,6 +4489,7 @@ goto_tabpage_tp(
|
|||||||
enter_tabpage(curtab, curbuf, trigger_enter_autocmds,
|
enter_tabpage(curtab, curbuf, trigger_enter_autocmds,
|
||||||
trigger_leave_autocmds);
|
trigger_leave_autocmds);
|
||||||
}
|
}
|
||||||
|
skip_win_fix_scroll = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -5481,7 +5483,7 @@ shell_new_rows(void)
|
|||||||
compute_cmdrow();
|
compute_cmdrow();
|
||||||
curtab->tp_ch_used = p_ch;
|
curtab->tp_ch_used = p_ch;
|
||||||
|
|
||||||
if (!p_spsc)
|
if (!p_spsc && !skip_win_fix_scroll)
|
||||||
win_fix_scroll(TRUE);
|
win_fix_scroll(TRUE);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@@ -6362,10 +6364,10 @@ win_fix_scroll(int resize)
|
|||||||
win_T *wp;
|
win_T *wp;
|
||||||
linenr_T lnum;
|
linenr_T lnum;
|
||||||
|
|
||||||
|
skip_update_topline = TRUE; // avoid scrolling in curs_rows()
|
||||||
FOR_ALL_WINDOWS(wp)
|
FOR_ALL_WINDOWS(wp)
|
||||||
{
|
{
|
||||||
// Skip when window height has not changed or when
|
// Skip when window height has not changed.
|
||||||
// buffer has less lines than the window height.
|
|
||||||
if (wp->w_height != wp->w_prev_height)
|
if (wp->w_height != wp->w_prev_height)
|
||||||
{
|
{
|
||||||
// Determine botline needed to avoid scrolling and set cursor.
|
// Determine botline needed to avoid scrolling and set cursor.
|
||||||
@@ -6387,8 +6389,9 @@ win_fix_scroll(int resize)
|
|||||||
wp->w_prev_height = wp->w_height;
|
wp->w_prev_height = wp->w_height;
|
||||||
wp->w_prev_winrow = wp->w_winrow;
|
wp->w_prev_winrow = wp->w_winrow;
|
||||||
}
|
}
|
||||||
|
skip_update_topline = FALSE;
|
||||||
// Ensure cursor is valid when not in normal mode or when resized.
|
// Ensure cursor is valid when not in normal mode or when resized.
|
||||||
if (!(get_real_state() & (MODE_NORMAL|MODE_CMDLINE)))
|
if (!(get_real_state() & (MODE_NORMAL|MODE_CMDLINE|MODE_TERMINAL)))
|
||||||
win_fix_cursor(FALSE);
|
win_fix_cursor(FALSE);
|
||||||
else if (resize)
|
else if (resize)
|
||||||
win_fix_cursor(TRUE);
|
win_fix_cursor(TRUE);
|
||||||
@@ -6435,11 +6438,8 @@ win_fix_cursor(int normal)
|
|||||||
else
|
else
|
||||||
{ // Ensure cursor stays visible if we are not in normal mode.
|
{ // Ensure cursor stays visible if we are not in normal mode.
|
||||||
wp->w_fraction = 0.5 * FRACTION_MULT;
|
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);
|
scroll_to_fraction(wp, wp->w_prev_height);
|
||||||
|
validate_botline_win(curwin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user