changeset 29581:4a79bca8a76e v9.0.0131

patch 9.0.0131: virtual text with Tab is not displayed correctly Commit: https://github.com/vim/vim/commit/783ef7214b6a33300bd83f616c1ead587370ce49 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Aug 1 16:11:06 2022 +0100 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.
author Bram Moolenaar <Bram@vim.org>
date Mon, 01 Aug 2022 17:15:02 +0200
parents 11db5a699881
children 902abc03f8ee
files runtime/doc/textprop.txt src/testdir/test_textprop.vim src/textprop.c src/version.c
diffstat 4 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/textprop.txt
+++ b/runtime/doc/textprop.txt
@@ -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*
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -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.')
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -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;
     }
 
--- a/src/version.c
+++ b/src/version.c
@@ -736,6 +736,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    131,
+/**/
     130,
 /**/
     129,