patch 9.0.0131: virtual text with Tab is not displayed correctly
Problem: Virtual text with Tab is not displayed correctly.
Solution: Change any Tab to a space.
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 2a74dc7..832343d 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -2197,7 +2197,7 @@
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 @@
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.')
diff --git a/src/textprop.c b/src/textprop.c
index f544a3c..6fefc6d 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -226,7 +226,8 @@
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 @@
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;
}
diff --git a/src/version.c b/src/version.c
index 6a8ad9b..09ac434 100644
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 131,
+/**/
130,
/**/
129,