]> granicus.if.org Git - vim/commitdiff
patch 8.1.1552: cursor position is wrong after sign column changes v8.1.1552
authorBram Moolenaar <Bram@vim.org>
Sun, 16 Jun 2019 11:55:40 +0000 (13:55 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 16 Jun 2019 11:55:40 +0000 (13:55 +0200)
Problem:    Cursor position is wrong after sign column appears or disappears.
            (Yegappan Lakshmanan)
Solution:   Call changed_line_abv_curs() instead of changed_cline_bef_curs().

src/sign.c
src/testdir/dumps/Test_sign_cursor_01.dump [new file with mode: 0644]
src/testdir/dumps/Test_sign_cursor_02.dump [new file with mode: 0644]
src/testdir/test_signs.vim
src/version.c

index e8288d628348f504e7be9d1cdb5226aacfe75634..240785385a0dfd6ca974599aaafdd255ae5287cf 100644 (file)
@@ -231,7 +231,7 @@ insert_sign(
            if (buf->b_signlist == NULL)
            {
                redraw_buf_later(buf, NOT_VALID);
-               changed_cline_bef_curs();
+               changed_line_abv_curs();
            }
 
            // first sign in signlist
@@ -531,7 +531,7 @@ buf_delsign(
     if (buf->b_signlist == NULL)
     {
        redraw_buf_later(buf, NOT_VALID);
-       changed_cline_bef_curs();
+       changed_line_abv_curs();
     }
 
     return lnum;
@@ -651,7 +651,7 @@ buf_delete_signs(buf_T *buf, char_u *group)
     if (buf->b_signlist != NULL && curwin != NULL)
     {
        redraw_buf_later(buf, NOT_VALID);
-       changed_cline_bef_curs();
+       changed_line_abv_curs();
     }
 
     lastp = &buf->b_signlist;
diff --git a/src/testdir/dumps/Test_sign_cursor_01.dump b/src/testdir/dumps/Test_sign_cursor_01.dump
new file mode 100644 (file)
index 0000000..9ca4481
--- /dev/null
@@ -0,0 +1,6 @@
+| +0#0000e05#a8a8a8255@1|x+0#0000000#ffffff0@72
+| +0#0000e05#a8a8a8255@1|x+0#0000000#ffffff0@1| @70
+|=+0&#ffff4012|>>m+0&#ffffff0@3| @68
+| +0#0000e05#a8a8a8255@1|y+0#0000000#ffffff0@3| @68
+|~+0#4040ff13&| @73
+| +0#0000000&@56|2|,|1| @10|A|l@1| 
diff --git a/src/testdir/dumps/Test_sign_cursor_02.dump b/src/testdir/dumps/Test_sign_cursor_02.dump
new file mode 100644 (file)
index 0000000..92643c3
--- /dev/null
@@ -0,0 +1,6 @@
+|x+0&#ffffff0@74
+>m@3| @70
+|y@3| @70
+|~+0#4040ff13&| @73
+|~| @73
+|:+0#0000000&|s|i|g|n| |u|n|p|l|a|c|e| |1|0| @40|2|,|1| @10|A|l@1| 
index 3b17eccf07825fe6f18272defc9937abb49fb6ed..140aa823495abc1e9c7a5a0a792a4893130a9a9e 100644 (file)
@@ -3,6 +3,8 @@
 source check.vim
 CheckFeature signs
 
+source screendump.vim
+
 func Test_sign()
   new
   call setline(1, ['a', 'b', 'c', 'd'])
@@ -1706,3 +1708,31 @@ func Test_sign_jump_func()
   sign undefine sign1
   enew! | only!
 endfunc
+
+" Test for correct cursor position after the sign column appears or disappears.
+func Test_sign_cursor_position()
+  if !CanRunVimInTerminal()
+    throw 'Skipped: cannot make screendumps'
+  endif
+
+  let lines =<< trim END
+       call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
+       call cursor(2,1)
+       sign define s1 texthl=Search text==>
+       redraw
+       sign place 10 line=2 name=s1
+  END
+  call writefile(lines, 'XtestSigncolumn')
+  let buf = RunVimInTerminal('-S XtestSigncolumn', {'rows': 6})
+  call VerifyScreenDump(buf, 'Test_sign_cursor_01', {})
+
+  " update cursor position calculation
+  call term_sendkeys(buf, "lh")
+  call term_sendkeys(buf, ":sign unplace 10\<CR>")
+  call VerifyScreenDump(buf, 'Test_sign_cursor_02', {})
+
+
+  " clean up
+  call StopVimInTerminal(buf)
+  call delete('XtestSigncolumn')
+endfunc
index b213bda110e62ac2da9da1c7c453c77ac20a6814..f960d52fa33d567e6c303e771e433b547ad4c13c 100644 (file)
@@ -777,6 +777,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1552,
 /**/
     1551,
 /**/