Skip to content

Commit

Permalink
patch 9.0.1691: wrong viewport restored for incsearch and smoothscroll
Browse files Browse the repository at this point in the history
Problem: wrong viewport restored for incsearch and smoothscroll
Solution: Save and restore skipcol as well

closes: #12713

Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: zeertzjq <zeertzjq@outlook.com>
  • Loading branch information
zeertzjq authored and chrisbra committed Aug 11, 2023
1 parent f6cdab3 commit 7b7b4cb
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/ex_getln.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ empty_pattern_magic(char_u *p, size_t len, magic_T magic_val)
typedef struct {
colnr_T vs_curswant;
colnr_T vs_leftcol;
colnr_T vs_skipcol;
linenr_T vs_topline;
# ifdef FEAT_DIFF
int vs_topfill;
Expand All @@ -135,6 +136,7 @@ save_viewstate(viewstate_T *vs)
{
vs->vs_curswant = curwin->w_curswant;
vs->vs_leftcol = curwin->w_leftcol;
vs->vs_skipcol = curwin->w_skipcol;
vs->vs_topline = curwin->w_topline;
# ifdef FEAT_DIFF
vs->vs_topfill = curwin->w_topfill;
Expand All @@ -148,6 +150,7 @@ restore_viewstate(viewstate_T *vs)
{
curwin->w_curswant = vs->vs_curswant;
curwin->w_leftcol = vs->vs_leftcol;
curwin->w_skipcol = vs->vs_skipcol;
curwin->w_topline = vs->vs_topline;
# ifdef FEAT_DIFF
curwin->w_topfill = vs->vs_topfill;
Expand Down
6 changes: 6 additions & 0 deletions src/testdir/dumps/Test_incsearch_restore_view_01.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
|<+0#4040ff13#ffffff0@2| +0#0000000&|1|8| |1|9| |2|0| |2|1| |2@1| |2
>3| |2|4| @15
@20
@20
@20
@10|1|,|6|1| @1|T|o|p|
6 changes: 6 additions & 0 deletions src/testdir/dumps/Test_incsearch_restore_view_02.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
| +0&#ffffff0@19
@20
@20
@20
|x+1&&@2| +0&&@16
|/|x@2> @15
22 changes: 22 additions & 0 deletions src/testdir/test_search.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,28 @@ func Test_incsearch_substitute_dump2()
call StopVimInTerminal(buf)
endfunc

func Test_incsearch_restore_view()
CheckOption incsearch
CheckScreendump

let lines =<< trim [CODE]
set incsearch nohlsearch
setlocal scrolloff=0 smoothscroll
call setline(1, [join(range(25), ' '), '', '', '', '', 'xxx'])
call feedkeys("2\<C-E>", 't')
[CODE]
call writefile(lines, 'Xincsearch_restore_view', 'D')
let buf = RunVimInTerminal('-S Xincsearch_restore_view', {'rows': 6, 'cols': 20})

call VerifyScreenDump(buf, 'Test_incsearch_restore_view_01', {})
call term_sendkeys(buf, '/xxx')
call VerifyScreenDump(buf, 'Test_incsearch_restore_view_02', {})
call term_sendkeys(buf, "\<Esc>")
call VerifyScreenDump(buf, 'Test_incsearch_restore_view_01', {})

call StopVimInTerminal(buf)
endfunc

func Test_pattern_is_uppercase_smartcase()
new
let input=['abc', 'ABC', 'Abc', 'abC']
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1691,
/**/
1690,
/**/
Expand Down

0 comments on commit 7b7b4cb

Please sign in to comment.