]> granicus.if.org Git - vim/commitdiff
patch 8.2.4955: text property in wrong position after auto-indent v8.2.4955
authorLemonBoy <thatlemon@gmail.com>
Sat, 14 May 2022 17:48:05 +0000 (18:48 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 14 May 2022 17:48:05 +0000 (18:48 +0100)
Problem:    Text property in wrong position after auto-indent.
Solution:   Adjust text property columns. (closes #10422, closes #7719)

src/change.c
src/testdir/test_textprop.vim
src/version.c

index b7618c5ba8fe2c71c7c4dbd0c1f551e672c21439..a9c3e19f4cf9aca115706e56999f6ce499aef654 100644 (file)
@@ -1372,7 +1372,8 @@ open_line(
     char_u     *next_line = NULL;      // copy of the next line
     char_u     *p_extra = NULL;        // what goes to next line
     int                less_cols = 0;          // less columns for mark in new line
-    int                less_cols_off = 0;      // columns to skip for mark adjust
+    int                less_cols_off = 0;      // columns to skip for mark and
+                                       // textprop adjustment
     pos_T      old_cursor;             // old cursor position
     int                newcol = 0;             // new cursor column
     int                newindent = 0;          // auto-indent of the new line
@@ -2151,9 +2152,9 @@ open_line(
        did_append = TRUE;
 #ifdef FEAT_PROP_POPUP
        if ((State & MODE_INSERT) && (State & VREPLACE_FLAG) == 0)
-           // properties after the split move to the next line
+           // Properties after the split move to the next line.
            adjust_props_for_split(curwin->w_cursor.lnum, curwin->w_cursor.lnum,
-                                                 curwin->w_cursor.col + 1, 0);
+                   curwin->w_cursor.col + 1, 0);
 #endif
     }
     else
@@ -2248,6 +2249,12 @@ open_line(
                    mark_col_adjust(curwin->w_cursor.lnum,
                                         curwin->w_cursor.col + less_cols_off,
                                                      1L, (long)-less_cols, 0);
+#ifdef FEAT_PROP_POPUP
+               // Keep into account the deleted blanks on the new line.
+               if (curbuf->b_has_textprop && less_cols_off != 0)
+                   adjust_prop_columns(curwin->w_cursor.lnum + 1, 0,
+                                                           -less_cols_off, 0);
+#endif
            }
            else
                changed_bytes(curwin->w_cursor.lnum, curwin->w_cursor.col);
index a2ba477e7147f3c0b68ce9e507d8054d16901327..50012acaf8ef7b76de9c33c3490f55079f52766d 100644 (file)
@@ -635,6 +635,18 @@ func Test_prop_open_line()
   call assert_equal(expected, prop_list(2))
   call DeletePropTypes()
 
+  " split at the space character with 'ai' active, the leading space is removed
+  " in the second line and the prop is shifted accordingly.
+  let expected = SetupOneLine() " 'xonex xtwoxx'
+  set ai
+  exe "normal 6|i\<CR>\<Esc>"
+  call assert_equal('xonex', getline(1))
+  call assert_equal('xtwoxx', getline(2))
+  let expected[1].col -= 6
+  call assert_equal(expected, prop_list(1) + prop_list(2))
+  set ai&
+  call DeletePropTypes()
+
   bwipe!
   set bs&
 endfunc
index b8712f21e25b18b6a42c9391d200bf253e392d05..62e2b0af69411f8eb7602245686290b1653db8a9 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4955,
 /**/
     4954,
 /**/