Skip to content

Commit 9d34d90

Browse files
committed
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)
1 parent c3c3e69 commit 9d34d90

File tree

4 files changed

+49
-1
lines changed

4 files changed

+49
-1
lines changed

src/ex_getln.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ getcmdline(
237237
int old_topfill;
238238
int init_topfill = curwin->w_topfill;
239239
# endif
240-
linenr_T old_botline;
240+
linenr_T old_botline, old_empty_rows;
241241
linenr_T init_botline = curwin->w_botline;
242+
linenr_T init_empty_rows = curwin->w_empty_rows;
242243
int did_incsearch = FALSE;
243244
int incsearch_postponed = FALSE;
244245
#endif
@@ -291,6 +292,7 @@ getcmdline(
291292
old_topfill = curwin->w_topfill;
292293
# endif
293294
old_botline = curwin->w_botline;
295+
old_empty_rows = curwin->w_empty_rows;
294296
#endif
295297

296298
/*
@@ -1075,6 +1077,7 @@ getcmdline(
10751077
old_topfill = init_topfill;
10761078
# endif
10771079
old_botline = init_botline;
1080+
old_empty_rows = init_empty_rows;
10781081
}
10791082
#endif
10801083
redrawcmd();
@@ -1804,6 +1807,7 @@ getcmdline(
18041807
old_topfill = curwin->w_topfill;
18051808
# endif
18061809
old_botline = curwin->w_botline;
1810+
old_empty_rows = curwin->w_empty_rows;
18071811
update_screen(NOT_VALID);
18081812
redrawcmdline();
18091813
}
@@ -2020,6 +2024,7 @@ getcmdline(
20202024
curwin->w_topfill = old_topfill;
20212025
# endif
20222026
curwin->w_botline = old_botline;
2027+
curwin->w_empty_rows = old_empty_rows;
20232028
changed_cline_bef_curs();
20242029
update_topline();
20252030

@@ -2114,6 +2119,7 @@ getcmdline(
21142119
curwin->w_topfill = old_topfill;
21152120
# endif
21162121
curwin->w_botline = old_botline;
2122+
curwin->w_empty_rows = old_empty_rows;
21172123
highlight_match = FALSE;
21182124
validate_cursor(); /* needed for TAB */
21192125
redraw_all_later(SOME_VALID);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
|.+0&#ffffff0@69
2+
@50| @19
3+
|.@69
4+
@50| @19
5+
@70
6+
|t+1&&|a|r|g|e+0&&|t| @63
7+
|@+0#4040ff13&@2| @66
8+
|/+0#0000000&|t|a|r|g> @64
9+
@70

src/testdir/test_search.vim

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
" Test for the search command
22

33
source shared.vim
4+
source screendump.vim
45

56
func Test_search_cmdline()
67
if !exists('+incsearch')
@@ -690,6 +691,36 @@ func Test_search_cmdline_incsearch_highlight_attr()
690691
bwipe!
691692
endfunc
692693

694+
func Test_incsearch_scrolling()
695+
if !CanRunVimInTerminal()
696+
return
697+
endif
698+
call assert_equal(0, &scrolloff)
699+
call writefile([
700+
\ 'let dots = repeat(".", 120)',
701+
\ 'set incsearch cmdheight=2 scrolloff=0',
702+
\ 'call setline(1, [dots, dots, dots, "", "target", dots, dots])',
703+
\ 'normal gg',
704+
\ 'redraw',
705+
\ ], 'Xscript')
706+
let buf = RunVimInTerminal('-S Xscript', {'rows': 9, 'cols': 70})
707+
" Need to send one key at a time to force a redraw
708+
call term_sendkeys(buf, '/')
709+
sleep 100m
710+
call term_sendkeys(buf, 't')
711+
sleep 100m
712+
call term_sendkeys(buf, 'a')
713+
sleep 100m
714+
call term_sendkeys(buf, 'r')
715+
sleep 100m
716+
call term_sendkeys(buf, 'g')
717+
call VerifyScreenDump(buf, 'Test_incsearch_scrolling_01', {})
718+
719+
call term_sendkeys(buf, "\<Esc>")
720+
call StopVimInTerminal(buf)
721+
call delete('Xscript')
722+
endfunc
723+
693724
func Test_search_undefined_behaviour()
694725
if !has("terminal")
695726
return

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
1767,
764766
/**/
765767
1766,
766768
/**/

0 commit comments

Comments
 (0)