vim-patch:8.0.1767: with 'incsearch' text may jump up and down

Problem:    With 'incsearch' text may jump up and down. ()
Solution:   Besides w_botline also save and restore w_empty_rows.
            (closes # 2530)
9d34d90210
This commit is contained in:
Jan Edmund Lazo 2019-12-22 11:24:48 -05:00
parent 9e9dcd4bd7
commit bc8da6cdbe
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15
2 changed files with 39 additions and 0 deletions

View File

@ -161,6 +161,8 @@ typedef struct command_line_state {
int init_topfill;
linenr_T old_botline;
linenr_T init_botline;
int old_empty_rows;
int init_empty_rows;
pos_T match_start;
pos_T match_end;
int did_incsearch;
@ -253,6 +255,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent)
s->init_topline = curwin->w_topline;
s->init_topfill = curwin->w_topfill;
s->init_botline = curwin->w_botline;
s->init_empty_rows = curwin->w_empty_rows;
if (s->firstc == -1) {
s->firstc = NUL;
@ -275,6 +278,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent)
s->old_topline = curwin->w_topline;
s->old_topfill = curwin->w_topfill;
s->old_botline = curwin->w_botline;
s->old_empty_rows = curwin->w_empty_rows;
assert(indent >= 0);
@ -449,6 +453,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent)
curwin->w_topline = s->old_topline;
curwin->w_topfill = s->old_topfill;
curwin->w_botline = s->old_botline;
curwin->w_empty_rows = s->old_empty_rows;
highlight_match = false;
validate_cursor(); // needed for TAB
redraw_all_later(SOME_VALID);
@ -1118,6 +1123,7 @@ static void command_line_next_incsearch(CommandLineState *s, bool next_match)
s->old_topline = curwin->w_topline;
s->old_topfill = curwin->w_topfill;
s->old_botline = curwin->w_botline;
s->old_empty_rows = curwin->w_empty_rows;
update_screen(NOT_VALID);
redrawcmdline();
} else {
@ -1243,6 +1249,7 @@ static int command_line_handle_key(CommandLineState *s)
s->old_topline = s->init_topline;
s->old_topfill = s->init_topfill;
s->old_botline = s->init_botline;
s->old_empty_rows = s->init_empty_rows;
}
redrawcmd();
} else if (ccline.cmdlen == 0 && s->c != Ctrl_W
@ -1876,6 +1883,7 @@ static int command_line_changed(CommandLineState *s)
curwin->w_topline = s->old_topline;
curwin->w_topfill = s->old_topfill;
curwin->w_botline = s->old_botline;
curwin->w_empty_rows = s->old_empty_rows;
changed_cline_bef_curs();
update_topline();

View File

@ -1,6 +1,7 @@
" Test for the search command
source shared.vim
source screendump.vim
func Test_search_cmdline()
" See test/functional/legacy/search_spec.lua
@ -549,6 +550,36 @@ func Test_incsearch_with_change()
call delete('Xis_change_script')
endfunc
func Test_incsearch_scrolling()
if !CanRunVimInTerminal()
return
endif
call assert_equal(0, &scrolloff)
call writefile([
\ 'let dots = repeat(".", 120)',
\ 'set incsearch cmdheight=2 scrolloff=0',
\ 'call setline(1, [dots, dots, dots, "", "target", dots, dots])',
\ 'normal gg',
\ 'redraw',
\ ], 'Xscript')
let buf = RunVimInTerminal('-S Xscript', {'rows': 9, 'cols': 70})
" Need to send one key at a time to force a redraw
call term_sendkeys(buf, '/')
sleep 100m
call term_sendkeys(buf, 't')
sleep 100m
call term_sendkeys(buf, 'a')
sleep 100m
call term_sendkeys(buf, 'r')
sleep 100m
call term_sendkeys(buf, 'g')
call VerifyScreenDump(buf, 'Test_incsearch_scrolling_01', {})
call term_sendkeys(buf, "\<Esc>")
call StopVimInTerminal(buf)
call delete('Xscript')
endfunc
func Test_search_undefined_behaviour()
if !has("terminal")
return