summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-08-24 12:24:37 +0100
committerBram Moolenaar <Bram@vim.org>2022-08-24 12:24:37 +0100
commitf5240b96f721b08d703340ff0b2e67b79fb8b821 (patch)
treeca491551437d156bb26b70f947fcb8fa091f541e
parent762df0477c32065498805e09c15adc468a6cc8ea (diff)
downloadvim-git-f5240b96f721b08d703340ff0b2e67b79fb8b821.tar.gz
patch 9.0.0252: cursor in wrong place after virtual textv9.0.0252
Problem: Cursor in wrong place after virtual text. Solution: Do not change the length of a virtual text property. (closes #10964)
-rw-r--r--src/testdir/dumps/Test_prop_text_change_arg_1.dump5
-rw-r--r--src/testdir/dumps/Test_prop_text_change_arg_2.dump5
-rw-r--r--src/testdir/test_textprop.vim36
-rw-r--r--src/textprop.c3
-rw-r--r--src/version.c2
5 files changed, 50 insertions, 1 deletions
diff --git a/src/testdir/dumps/Test_prop_text_change_arg_1.dump b/src/testdir/dumps/Test_prop_text_change_arg_1.dump
new file mode 100644
index 000000000..174af0786
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_text_change_arg_1.dump
@@ -0,0 +1,5 @@
+>S+0&#ffffff0|e|t|E|r@1|o|r|C|o|d|e|(| |i+0&#ffd7ff255|d|:|-+0#4040ff13#ffffff0|1+0#0000000&|0|,| |i+0&#ffd7ff255|d|:|-+0#4040ff13#ffffff0|2+0#0000000&|0| |)| @29
+|s|e|c|o|n|d| |l|i|n|e| @48
+|~+0#4040ff13&| @58
+|~| @58
+| +0#0000000&@41|1|,|1| @10|A|l@1|
diff --git a/src/testdir/dumps/Test_prop_text_change_arg_2.dump b/src/testdir/dumps/Test_prop_text_change_arg_2.dump
new file mode 100644
index 000000000..57e9a465d
--- /dev/null
+++ b/src/testdir/dumps/Test_prop_text_change_arg_2.dump
@@ -0,0 +1,5 @@
+|S+0&#ffffff0|e|t|E|r@1|o|r|C|o|d|e|(| |i+0&#ffd7ff255|d|:|-+0#4040ff13#ffffff0|1+0#0000000&|2|3>4|,| |i+0&#ffd7ff255|d|:|-+0#4040ff13#ffffff0|2+0#0000000&|0| |)| @27
+|s|e|c|o|n|d| |l|i|n|e| @48
+|~+0#4040ff13&| @58
+|~| @58
+| +0#0000000&@41|1|,|1|8|-|2@1| @6|A|l@1|
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 0c7e91d09..60bf48c12 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -3091,4 +3091,40 @@ func Test_insert_text_with_padding()
call delete('XscriptPropsPadded')
endfunc
+func Test_insert_text_change_arg()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ vim9script
+ setline(1, ['SetErrorCode( 10, 20 )', 'second line'])
+ prop_type_add('param', {highlight: 'DiffChange', start_incl: 1})
+ prop_type_add('padd', {highlight: 'NonText', start_incl: 1})
+ prop_add(1, 15, {
+ type: 'param',
+ text: 'id:',
+ })
+ prop_add(1, 15, {
+ type: 'padd',
+ text: '-',
+ })
+ prop_add(1, 19, {
+ type: 'param',
+ text: 'id:',
+ })
+ prop_add(1, 19, {
+ type: 'padd',
+ text: '-',
+ })
+ END
+ call writefile(lines, 'XscriptPropsChange')
+ let buf = RunVimInTerminal('-S XscriptPropsChange', #{rows: 5, cols: 60})
+ call VerifyScreenDump(buf, 'Test_prop_text_change_arg_1', {})
+
+ call term_sendkeys(buf, "ggf1cw1234\<Esc>")
+ call VerifyScreenDump(buf, 'Test_prop_text_change_arg_2', {})
+
+ call StopVimInTerminal(buf)
+ call delete('XscriptPropsChange')
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/textprop.c b/src/textprop.c
index 31e1be3bb..0ba5c20b3 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -2127,7 +2127,8 @@ adjust_prop(
else
prop->tp_col += added;
}
- else if (prop->tp_len > 0 && prop->tp_col + prop->tp_len > col)
+ else if (prop->tp_len > 0 && prop->tp_col + prop->tp_len > col
+ && prop->tp_id >= 0) // don't change length for virtual text
{
int after = col - added - (prop->tp_col - 1 + prop->tp_len);
diff --git a/src/version.c b/src/version.c
index 1d1de74d9..2cd1e50ea 100644
--- a/src/version.c
+++ b/src/version.c
@@ -732,6 +732,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 252,
+/**/
251,
/**/
250,