patch 9.0.1691: wrong viewport restored for incsearch and smoothscroll

16 views
Skip to first unread message

Christian Brabandt

unread,
Aug 11, 2023, 6:00:11 PM8/11/23
to vim...@googlegroups.com
patch 9.0.1691: wrong viewport restored for incsearch and smoothscroll

Commit: https://github.com/vim/vim/commit/7b7b4cb6f274e7bace127107b0d2752133c4020b
Author: zeertzjq <zeer...@outlook.com>
Date: Fri Aug 11 23:48:27 2023 +0200

patch 9.0.1691: wrong viewport restored for incsearch and smoothscroll

Problem: wrong viewport restored for incsearch and smoothscroll
Solution: Save and restore skipcol as well

closes: #12713

Signed-off-by: Christian Brabandt <c...@256bit.org>
Co-authored-by: zeertzjq <zeer...@outlook.com>

diff --git a/src/ex_getln.c b/src/ex_getln.c
index 00d32920b..55b4632ac 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -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;
@@ -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;
@@ -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;
diff --git a/src/testdir/dumps/Test_incsearch_restore_view_01.dump b/src/testdir/dumps/Test_incsearch_restore_view_01.dump
new file mode 100644
index 000000000..6ad0b245f
--- /dev/null
+++ b/src/testdir/dumps/Test_incsearch_restore_view_01.dump
@@ -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|
diff --git a/src/testdir/dumps/Test_incsearch_restore_view_02.dump b/src/testdir/dumps/Test_incsearch_restore_view_02.dump
new file mode 100644
index 000000000..2a2c9a2b8
--- /dev/null
+++ b/src/testdir/dumps/Test_incsearch_restore_view_02.dump
@@ -0,0 +1,6 @@
+| +0&#ffffff0@19
+@20
+@20
+@20
+|x+1&&@2| +0&&@16
+|/|x@2> @15
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index ef4475165..f3bc6bff7 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -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']
diff --git a/src/version.c b/src/version.c
index d8b9f0ef9..f0ec4bc2d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -695,6 +695,8 @@ static char *(features[]) =

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

Christ van Willegen

unread,
Aug 12, 2023, 5:45:46 AM8/12/23
to vim...@googlegroups.com
I tried contacting the author, but got their email address wrong, so I'll just copy my message here. Would you accept this patch, or do you want a PR?




I looked at your PR, and since things are still 'in flux', I thought
I'd share this off-list, beacuse I would like to add to your PR, and
that doesn't work well at the moment :-)

Here's my diff:

diff --git a/src/testdir/dumps/Test_incsearch_restore_view_02.dump
b/src/testdir/dumps/Test_incsearch_restore_view_02.dump
index 2a2c9a2b8..c17163947 100644
--- a/src/testdir/dumps/Test_incsearch_restore_view_02.dump
+++ b/src/testdir/dumps/Test_incsearch_restore_view_02.dump
@@ -2,5 +2,5 @@
 @20
 @20
 @20
-|x+1&&@2| +0&&@16
-|/|x@2> @15
+|x+1&&@1|x+0&&| @16
+|/|x@1> @16
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index f3bc6bff7..1a9f49bfe 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -2094,8 +2094,10 @@ func Test_incsearch_restore_view()
   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 term_sendkeys(buf, '/xx')
   call VerifyScreenDump(buf, 'Test_incsearch_restore_view_02', {})
+ call term_sendkeys(buf, 'x')
+ call VerifyScreenDump(buf, 'Test_incsearch_restore_view_03', {})
   call term_sendkeys(buf, "\<Esc>")
   call VerifyScreenDump(buf, 'Test_incsearch_restore_view_01', {})




Here's the new Screendump file. It checks a jumping viewport I noticed
after typing 2 xx after the /:
$ cat dumps/Test_incsearch_restore_view_03.dump
| +0&#ffffff0@19
@20
@20
@20
|x+1&&@2| +0&&@16
|/|x@2> @15

(this is basically the old ...02.dump, because I shifted them one up...)

Does this make sense?


Christ van Willegen

Christian Brabandt

unread,
Aug 12, 2023, 2:20:01 PM8/12/23
to vim...@googlegroups.com

On Sa, 12 Aug 2023, Christ van Willegen wrote:

> Does this make sense?

Applied, thanks.

Best,
Christian
--
Only great masters of style can succeed in being obtuse.
-- Oscar Wilde

Most UNIX programmers are great masters of style.
-- The Unnamed Usenetter
Reply all
Reply to author
Forward
0 new messages