Skip to content

Commit 88b79cb

Browse files
committed
patch 9.0.0439: cursor wrong if inserting before line with virtual text above
Problem: Cursor wrong if inserting before line with virtual text above. Solution: Add the width of the "above" virtual text to the cursor position. (issue #11084)
1 parent 04e0ed1 commit 88b79cb

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

src/charset.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1576,6 +1576,9 @@ getvcol(
15761576
if (((State & MODE_INSERT) == 0 || cts.cts_start_incl) && !on_NUL)
15771577
// cursor is after inserted text, unless on the NUL
15781578
vcol += cts.cts_cur_text_width;
1579+
else
1580+
// insertion also happens after the "above" virtual text
1581+
vcol += cts.cts_first_char;
15791582
#endif
15801583
*cursor = vcol + head; // cursor at start
15811584
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
|f+0&#ffff4012|i|r|s|t| |t|h|i|n|g| |a|b|o|v|e| @42
2+
|s+0&#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| @41
3+
>o+0&#ffffff0|n|e| |t|w|o| @52
4+
|t|h|r|e@1| |f|o|u|r| @49
5+
|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @46
6+
|f+0&#ffffff0|i|v|e| |s|i|x| @51
7+
|~+0#4040ff13&| @58
8+
|~| @58
9+
|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@29|1|,|1|-|1|2|1| @6|A|l@1|
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
|f+0&#ffff4012|i|r|s|t| |t|h|i|n|g| |a|b|o|v|e| @42
2+
|s+0&#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| @41
3+
|i+0&#ffffff0|n|s|e|r|t|e|d> |o|n|e| |t|w|o| @43
4+
|t|h|r|e@1| |f|o|u|r| @49
5+
|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @46
6+
|f+0&#ffffff0|i|v|e| |s|i|x| @51
7+
|~+0#4040ff13&| @58
8+
|~| @58
9+
| +0#0000000&@41|1|,|9|-|1|2|9| @6|A|l@1|

src/testdir/test_textprop.vim

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2865,6 +2865,11 @@ func Test_props_with_text_above()
28652865
let buf = RunVimInTerminal('-S XscriptPropsWithTextAbove', #{rows: 9, cols: 60})
28662866
call VerifyScreenDump(buf, 'Test_prop_with_text_above_1', {})
28672867

2868+
call term_sendkeys(buf, "ggI")
2869+
call VerifyScreenDump(buf, 'Test_prop_with_text_above_2', {})
2870+
call term_sendkeys(buf, "inserted \<Esc>")
2871+
call VerifyScreenDump(buf, 'Test_prop_with_text_above_3', {})
2872+
28682873
call StopVimInTerminal(buf)
28692874
endfunc
28702875

src/version.c

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

704704
static int included_patches[] =
705705
{ /* Add new patch number below this line */
706+
/**/
707+
439,
706708
/**/
707709
438,
708710
/**/

0 commit comments

Comments
 (0)