]> granicus.if.org Git - vim/commitdiff
patch 9.0.0130: cursor position wrong when inserting around virtual text v9.0.0130
authorBram Moolenaar <Bram@vim.org>
Mon, 1 Aug 2022 14:52:55 +0000 (15:52 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 1 Aug 2022 14:52:55 +0000 (15:52 +0100)
Problem:    Cursor position wrong when inserting around virtual text.
Solution:   Update the cursor position properly.

src/drawline.c
src/edit.c
src/testdir/dumps/Test_prop_inserts_text_1.dump
src/testdir/dumps/Test_prop_inserts_text_2.dump
src/testdir/test_textprop.vim
src/version.c

index af8c053b7c747f10287f2ff470c5c8d9c5c7f845..949d6f998aecfb5bfe18a39d864b91a85617f689 100644 (file)
@@ -1589,13 +1589,6 @@ win_line(
                                    n_attr_skip = added;
                                }
                            }
-
-                           // If the cursor is on or after this position,
-                           // move it forward.
-                           if (wp == curwin
-                                   && lnum == curwin->w_cursor.lnum
-                                   && curwin->w_cursor.col >= vcol)
-                               curwin->w_cursor.col += n_extra;
                        }
                        // reset the ID in the copy to avoid it being used
                        // again
index 0e715c2d1b0fa5eeb27b625079e6eb14ab80d5ca..c3aa888780aba3896b64308545f5e87c80a34f78 100644 (file)
@@ -288,8 +288,13 @@ edit(
     conceal_check_cursor_line(cursor_line_was_concealed);
 #endif
 
-    // need to position cursor again when on a TAB
-    if (gchar_cursor() == TAB)
+    // Need to position cursor again when on a TAB and when on a char with
+    // virtual text.
+    if (gchar_cursor() == TAB
+#ifdef FEAT_PROP_POPUP
+           || curbuf->b_has_textprop
+#endif
+       )
        curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL);
 
     /*
index f536bd50d2c8f6746313afeca39037edc96de93b..dfa491b1af5b86d2c9702e774fc69c49ad47a538 100644 (file)
@@ -1,6 +1,6 @@
 |i+0&#ffffff0|n|s|e|r|t| |s|o|m|e| |t|e|x|t| |S+0#ffffff16#e000002|O|M|E| |h+0#0000000#ffffff0|e|r|e| |a|n|d| |o|t|h|e|r| |t|e|x|t| |O+0&#ffff4012|T|H|E|R| |t+0&#ffffff0|h|e|r|e| |a|n|d| |s|o
-|m|e| |m|o|r|e| |t|e|x|t| |a|f|t|e|r| |M+0&#5fd7ff255|O|R|E| |w+0&#ffffff0|r|a|p@1|i|n|g> @27
+|m|e| |m|o|r|e| |t|e|x|t| |a|f|t|e|r| |M+0&#5fd7ff255|O|R|E| |w+0&#ffffff0|r|a|p@1|i|n>g| @27
 |~+0#4040ff13&| @58
 |~| @58
 |~| @58
-| +0#0000000&@41|1|,|7@1|-|9|3| @6|A|l@1| 
+| +0#0000000&@41|1|,|7|6|-|9|2| @6|A|l@1| 
index 4d8b725325f27c39be39bf503b8b57034fd7ff9e..360f00ddcc054c5c952ae5609f897ca9876562a1 100644 (file)
@@ -1,6 +1,6 @@
 | +0#0000e05#a8a8a8255@1|i+0#0000000#ffffff0|n|s|e|r|t| |s|o|m|e| |t|e|x|t| |S+0#ffffff16#e000002|O|M|E| |h+0#0000000#ffffff0|e|r|e| |a|n|d| |o|t|h|e|r| |t|e|x|t| |O+0&#ffff4012|T|H|E|R| |t+0&#ffffff0|h|e|r|e| |a|n|d| 
-| +0#0000e05#a8a8a8255@1|s+0#0000000#ffffff0|o|m|e| |m|o|r|e| |t|e|x|t| |a|f|t|e|r| |M+0&#5fd7ff255|O|R|E| |w+0&#ffffff0|r|a|p@1|i|n|g> @23
+| +0#0000e05#a8a8a8255@1|s+0#0000000#ffffff0|o|m|e| |m|o|r|e| |t|e|x|t| |a|f|t|e|r| |M+0&#5fd7ff255|O|R|E| |w+0&#ffffff0|r|a|p@1|i|n>g| @23
 |~+0#4040ff13&| @58
 |~| @58
 |~| @58
-| +0#0000000&@41|1|,|7@1|-|9|3| @6|A|l@1| 
+| +0#0000000&@41|1|,|7|6|-|9|2| @6|A|l@1| 
index 5ac787e5e2ddcd4352ae416a26270c7f001d8c76..2a74dc7e3c75c88d71a221a226af0f8f1659668b 100644 (file)
@@ -2256,4 +2256,20 @@ func Test_removed_prop_with_text_cleans_up_array()
   bwipe!
 endfunc
 
+def Test_insert_text_before_virtual_text()
+  new foobar
+  setline(1, '12345678')
+  prop_type_add('test', {highlight: 'Search'})
+  prop_add(1, 5, {
+    type: 'test',
+    text: ' virtual text '
+    })
+  normal! f4axyz
+  normal! f5iXYZ
+  assert_equal('1234xyzXYZ5678', getline(1))
+
+  prop_type_delete('test')
+  bwipe!
+enddef
+
 " vim: shiftwidth=2 sts=2 expandtab
index f4c63f1f709e0c8e031a649b1dcdb107a15323e3..6a8ad9b24f7f3b8abd16f89199626a219394f3c5 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    130,
 /**/
     129,
 /**/