summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-09-10 22:32:14 +0100
committerBram Moolenaar <Bram@vim.org>2022-09-10 22:32:14 +0100
commit88b79cb7d47e2e1fee1baf4016c50b861e6b21c4 (patch)
tree7d17b0fa0635124fca3ff7bbe986452142f630d9
parent04e0ed1ddf399d609dbcb7dbf19e531da1fe6172 (diff)
downloadvim-git-88b79cb7d47e2e1fee1baf4016c50b861e6b21c4.tar.gz
patch 9.0.0439: cursor wrong if inserting before line with virtual text abovev9.0.0439
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)
-rw-r--r--src/charset.c3
-rw-r--r--src/testdir/dumps/Test_prop_with_text_above_2.dump9
-rw-r--r--src/testdir/dumps/Test_prop_with_text_above_3.dump9
-rw-r--r--src/testdir/test_textprop.vim5
-rw-r--r--src/version.c2
5 files changed, 28 insertions, 0 deletions
diff --git a/src/charset.c b/src/charset.c
index acf60999d..a19e55b62 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -1576,6 +1576,9 @@ getvcol(
if (((State & MODE_INSERT) == 0 || cts.cts_start_incl) && !on_NUL)
// cursor is after inserted text, unless on the NUL
vcol += cts.cts_cur_text_width;
+ else
+ // insertion also happens after the "above" virtual text
+ vcol += cts.cts_first_char;
#endif
*cursor = vcol + head; // cursor at start
}
diff --git a/src/testdir/dumps/Test_prop_with_text_above_2.dump b/src/testdir/dumps/Test_prop_with_text_above_2.dump
new file mode 100644
index 000000000..7f45faf11
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_with_text_above_2.dump
@@ -0,0 +1,9 @@
+|f+0&#ffff4012|i|r|s|t| |t|h|i|n|g| |a|b|o|v|e| @42
+|s+0&#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| @41
+>o+0&#ffffff0|n|e| |t|w|o| @52
+|t|h|r|e@1| |f|o|u|r| @49
+|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @46
+|f+0&#ffffff0|i|v|e| |s|i|x| @51
+|~+0#4040ff13&| @58
+|~| @58
+|-+2#0000000&@1| |I|N|S|E|R|T| |-@1| +0&&@29|1|,|1|-|1|2|1| @6|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_with_text_above_3.dump b/src/testdir/dumps/Test_prop_with_text_above_3.dump
new file mode 100644
index 000000000..8a4b1d491
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_with_text_above_3.dump
@@ -0,0 +1,9 @@
+|f+0&#ffff4012|i|r|s|t| |t|h|i|n|g| |a|b|o|v|e| @42
+|s+0&#ffd7ff255|e|c|o|n|d| |t|h|i|n|g| |a|b|o|v|e| @41
+|i+0&#ffffff0|n|s|e|r|t|e|d> |o|n|e| |t|w|o| @43
+|t|h|r|e@1| |f|o|u|r| @49
+|a+0&#ffff4012|n|o|t|h|e|r| |t|h|i|n|g| @46
+|f+0&#ffffff0|i|v|e| |s|i|x| @51
+|~+0#4040ff13&| @58
+|~| @58
+| +0#0000000&@41|1|,|9|-|1|2|9| @6|A|l@1|
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index d89f84ced..f97772ce6 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -2865,6 +2865,11 @@ func Test_props_with_text_above()
let buf = RunVimInTerminal('-S XscriptPropsWithTextAbove', #{rows: 9, cols: 60})
call VerifyScreenDump(buf, 'Test_prop_with_text_above_1', {})
+ call term_sendkeys(buf, "ggI")
+ call VerifyScreenDump(buf, 'Test_prop_with_text_above_2', {})
+ call term_sendkeys(buf, "inserted \<Esc>")
+ call VerifyScreenDump(buf, 'Test_prop_with_text_above_3', {})
+
call StopVimInTerminal(buf)
endfunc
diff --git a/src/version.c b/src/version.c
index ac89e77c0..3345c21c4 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 439,
+/**/
438,
/**/
437,