Skip to content

Commit f85e40a

Browse files
committed
patch 8.1.1552: cursor position is wrong after sign column changes
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().
1 parent 6c17543 commit f85e40a

5 files changed

Lines changed: 47 additions & 3 deletions

File tree

src/sign.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ insert_sign(
231231
if (buf->b_signlist == NULL)
232232
{
233233
redraw_buf_later(buf, NOT_VALID);
234-
changed_cline_bef_curs();
234+
changed_line_abv_curs();
235235
}
236236

237237
// first sign in signlist
@@ -531,7 +531,7 @@ buf_delsign(
531531
if (buf->b_signlist == NULL)
532532
{
533533
redraw_buf_later(buf, NOT_VALID);
534-
changed_cline_bef_curs();
534+
changed_line_abv_curs();
535535
}
536536

537537
return lnum;
@@ -651,7 +651,7 @@ buf_delete_signs(buf_T *buf, char_u *group)
651651
if (buf->b_signlist != NULL && curwin != NULL)
652652
{
653653
redraw_buf_later(buf, NOT_VALID);
654-
changed_cline_bef_curs();
654+
changed_line_abv_curs();
655655
}
656656

657657
lastp = &buf->b_signlist;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
| +0#0000e05#a8a8a8255@1|x+0#0000000#ffffff0@72
2+
| +0#0000e05#a8a8a8255@1|x+0#0000000#ffffff0@1| @70
3+
|=+0&#ffff4012|>>m+0&#ffffff0@3| @68
4+
| +0#0000e05#a8a8a8255@1|y+0#0000000#ffffff0@3| @68
5+
|~+0#4040ff13&| @73
6+
| +0#0000000&@56|2|,|1| @10|A|l@1|
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
|x+0&#ffffff0@74
2+
>m@3| @70
3+
|y@3| @70
4+
|~+0#4040ff13&| @73
5+
|~| @73
6+
|:+0#0000000&|s|i|g|n| |u|n|p|l|a|c|e| |1|0| @40|2|,|1| @10|A|l@1|

src/testdir/test_signs.vim

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
source check.vim
44
CheckFeature signs
55

6+
source screendump.vim
7+
68
func Test_sign()
79
new
810
call setline(1, ['a', 'b', 'c', 'd'])
@@ -1706,3 +1708,31 @@ func Test_sign_jump_func()
17061708
sign undefine sign1
17071709
enew! | only!
17081710
endfunc
1711+
1712+
" Test for correct cursor position after the sign column appears or disappears.
1713+
func Test_sign_cursor_position()
1714+
if !CanRunVimInTerminal()
1715+
throw 'Skipped: cannot make screendumps'
1716+
endif
1717+
1718+
let lines =<< trim END
1719+
call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
1720+
call cursor(2,1)
1721+
sign define s1 texthl=Search text==>
1722+
redraw
1723+
sign place 10 line=2 name=s1
1724+
END
1725+
call writefile(lines, 'XtestSigncolumn')
1726+
let buf = RunVimInTerminal('-S XtestSigncolumn', {'rows': 6})
1727+
call VerifyScreenDump(buf, 'Test_sign_cursor_01', {})
1728+
1729+
" update cursor position calculation
1730+
call term_sendkeys(buf, "lh")
1731+
call term_sendkeys(buf, ":sign unplace 10\<CR>")
1732+
call VerifyScreenDump(buf, 'Test_sign_cursor_02', {})
1733+
1734+
1735+
" clean up
1736+
call StopVimInTerminal(buf)
1737+
call delete('XtestSigncolumn')
1738+
endfunc

src/version.c

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

778778
static int included_patches[] =
779779
{ /* Add new patch number below this line */
780+
/**/
781+
1552,
780782
/**/
781783
1551,
782784
/**/

0 commit comments

Comments
 (0)