]> granicus.if.org Git - vim/commitdiff
patch 9.0.0131: virtual text with Tab is not displayed correctly v9.0.0131
authorBram Moolenaar <Bram@vim.org>
Mon, 1 Aug 2022 15:11:06 +0000 (16:11 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 1 Aug 2022 15:11:06 +0000 (16:11 +0100)
Problem:    Virtual text with Tab is not displayed correctly.
Solution:   Change any Tab to a space.

runtime/doc/textprop.txt
src/testdir/test_textprop.vim
src/textprop.c
src/version.c

index a0c8c348d70770446e4306f94abe5572a5822f16..150d466e27dc3235323349a3ccf41f70d0393933 100644 (file)
@@ -187,6 +187,8 @@ prop_add({lnum}, {col}, {props})
                in the text will move the cursor to the first character after
                the text, or the last character of the line.
                A negative "id" will be chosen and is returned.  Once a
+               Any Tab in the text will be changed to a space (Rationale:
+               otherwise the size of the text is difficult to compute).
                property with "text" has been added for a buffer then using a
                negative "id" for any other property will give an error:
                *E1293*
index 2a74dc7e3c75c88d71a221a226af0f8f1659668b..832343de14f0be466c9d2f6d70c7d51a53050c8f 100644 (file)
@@ -2197,7 +2197,7 @@ func Test_prop_inserts_text()
       call prop_type_add('otherprop', #{highlight: 'Search'})
       call prop_type_add('moreprop', #{highlight: 'DiffAdd'})
       call prop_add(1, 18, #{type: 'someprop', text: 'SOME '})
-      call prop_add(1, 38, #{type: 'otherprop', text: 'OTHER '})
+      call prop_add(1, 38, #{type: 'otherprop', text: "OTHER\t"})
       call prop_add(1, 69, #{type: 'moreprop', text: 'MORE '})
       redraw
       normal $
@@ -2222,7 +2222,7 @@ func Test_props_with_text_after()
       call prop_type_add('afterprop', #{highlight: 'Search'})
       call prop_type_add('belowprop', #{highlight: 'DiffAdd'})
       call prop_add(1, 0, #{type: 'rightprop', text: ' RIGHT ', text_align: 'right'})
-      call prop_add(1, 0, #{type: 'afterprop', text: ' AFTER ', text_align: 'after'})
+      call prop_add(1, 0, #{type: 'afterprop', text: "\tAFTER\t", text_align: 'after'})
       call prop_add(1, 0, #{type: 'belowprop', text: ' BELOW ', text_align: 'below'})
 
       call setline(2, 'Last line.')
index f544a3ce5a1701a9ae96e3cc32217115aba770a9..6fefc6d24cf5efef4f27286974f23615eb696495 100644 (file)
@@ -226,7 +226,8 @@ prop_add_one(
 
     if (text != NULL)
     {
-       garray_T *gap = &buf->b_textprop_text;
+       garray_T    *gap = &buf->b_textprop_text;
+       char_u      *p;
 
        // double check we got the right ID
        if (-id - 1 != gap->ga_len)
@@ -236,6 +237,11 @@ prop_add_one(
        if (ga_grow(gap, 1) == FAIL)
            goto theend;
        ((char_u **)gap->ga_data)[gap->ga_len++] = text;
+
+       // change any Tab to a Space to make it simpler to compute the size
+       for (p = text; *p != NUL; MB_PTR_ADV(p))
+           if (*p == TAB)
+               *p = ' ';
        text = NULL;
     }
 
index 6a8ad9b24f7f3b8abd16f89199626a219394f3c5..09ac434b5ba5236b9b7d0f0691706e2fb6fe9577 100644 (file)
@@ -735,6 +735,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    131,
 /**/
     130,
 /**/