mirror of
https://github.com/neovim/neovim.git
synced 2025-10-06 18:06:30 +00:00
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:
@@ -161,6 +161,8 @@ typedef struct command_line_state {
|
|||||||
int init_topfill;
|
int init_topfill;
|
||||||
linenr_T old_botline;
|
linenr_T old_botline;
|
||||||
linenr_T init_botline;
|
linenr_T init_botline;
|
||||||
|
int old_empty_rows;
|
||||||
|
int init_empty_rows;
|
||||||
pos_T match_start;
|
pos_T match_start;
|
||||||
pos_T match_end;
|
pos_T match_end;
|
||||||
int did_incsearch;
|
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_topline = curwin->w_topline;
|
||||||
s->init_topfill = curwin->w_topfill;
|
s->init_topfill = curwin->w_topfill;
|
||||||
s->init_botline = curwin->w_botline;
|
s->init_botline = curwin->w_botline;
|
||||||
|
s->init_empty_rows = curwin->w_empty_rows;
|
||||||
|
|
||||||
if (s->firstc == -1) {
|
if (s->firstc == -1) {
|
||||||
s->firstc = NUL;
|
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_topline = curwin->w_topline;
|
||||||
s->old_topfill = curwin->w_topfill;
|
s->old_topfill = curwin->w_topfill;
|
||||||
s->old_botline = curwin->w_botline;
|
s->old_botline = curwin->w_botline;
|
||||||
|
s->old_empty_rows = curwin->w_empty_rows;
|
||||||
|
|
||||||
assert(indent >= 0);
|
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_topline = s->old_topline;
|
||||||
curwin->w_topfill = s->old_topfill;
|
curwin->w_topfill = s->old_topfill;
|
||||||
curwin->w_botline = s->old_botline;
|
curwin->w_botline = s->old_botline;
|
||||||
|
curwin->w_empty_rows = s->old_empty_rows;
|
||||||
highlight_match = false;
|
highlight_match = false;
|
||||||
validate_cursor(); // needed for TAB
|
validate_cursor(); // needed for TAB
|
||||||
redraw_all_later(SOME_VALID);
|
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_topline = curwin->w_topline;
|
||||||
s->old_topfill = curwin->w_topfill;
|
s->old_topfill = curwin->w_topfill;
|
||||||
s->old_botline = curwin->w_botline;
|
s->old_botline = curwin->w_botline;
|
||||||
|
s->old_empty_rows = curwin->w_empty_rows;
|
||||||
update_screen(NOT_VALID);
|
update_screen(NOT_VALID);
|
||||||
redrawcmdline();
|
redrawcmdline();
|
||||||
} else {
|
} else {
|
||||||
@@ -1243,6 +1249,7 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
s->old_topline = s->init_topline;
|
s->old_topline = s->init_topline;
|
||||||
s->old_topfill = s->init_topfill;
|
s->old_topfill = s->init_topfill;
|
||||||
s->old_botline = s->init_botline;
|
s->old_botline = s->init_botline;
|
||||||
|
s->old_empty_rows = s->init_empty_rows;
|
||||||
}
|
}
|
||||||
redrawcmd();
|
redrawcmd();
|
||||||
} else if (ccline.cmdlen == 0 && s->c != Ctrl_W
|
} 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_topline = s->old_topline;
|
||||||
curwin->w_topfill = s->old_topfill;
|
curwin->w_topfill = s->old_topfill;
|
||||||
curwin->w_botline = s->old_botline;
|
curwin->w_botline = s->old_botline;
|
||||||
|
curwin->w_empty_rows = s->old_empty_rows;
|
||||||
changed_cline_bef_curs();
|
changed_cline_bef_curs();
|
||||||
update_topline();
|
update_topline();
|
||||||
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
" Test for the search command
|
" Test for the search command
|
||||||
|
|
||||||
source shared.vim
|
source shared.vim
|
||||||
|
source screendump.vim
|
||||||
|
|
||||||
func Test_search_cmdline()
|
func Test_search_cmdline()
|
||||||
" See test/functional/legacy/search_spec.lua
|
" See test/functional/legacy/search_spec.lua
|
||||||
@@ -549,6 +550,36 @@ func Test_incsearch_with_change()
|
|||||||
call delete('Xis_change_script')
|
call delete('Xis_change_script')
|
||||||
endfunc
|
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()
|
func Test_search_undefined_behaviour()
|
||||||
if !has("terminal")
|
if !has("terminal")
|
||||||
return
|
return
|
||||||
|
Reference in New Issue
Block a user