changeset 30306:43d942ff32ce v9.0.0489

patch 9.0.0489: using "end_lnum" with virtual text causes problems Commit: https://github.com/vim/vim/commit/fb593c5350e8fe23b608ded5a011cd7eefe73922 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Sep 17 18:57:36 2022 +0100 patch 9.0.0489: using "end_lnum" with virtual text causes problems Problem: Using "end_lnum" with virtual text causes problems. Solution: Disallow using "end_lnum" with virtual text. (closes https://github.com/vim/vim/issues/11151) Also disallow "end_col" and "length".
author Bram Moolenaar <Bram@vim.org>
date Sat, 17 Sep 2022 20:00:03 +0200
parents b00800d36297
children bf1d735c4bc9
files src/errors.h src/testdir/test_textprop.vim src/textprop.c src/version.c
diffstat 4 files changed, 25 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/errors.h
+++ b/src/errors.h
@@ -3338,3 +3338,7 @@ EXTERN char e_custom_list_completion_fun
 EXTERN char e_cannot_use_type_with_this_variable_str[]
 	INIT(= N_("E1304: Cannot use type with this variable: %s"));
 #endif
+#ifdef FEAT_PROP_POPUP
+EXTERN char e_cannot_use_length_endcol_and_endlnum_with_text[]
+	INIT(= N_("E1305: Cannot use \"length\", \"end_col\" and \"end_lnum\" with \"text\""));
+#endif
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -2578,13 +2578,22 @@ func Test_prop_inserts_text_highlight()
   call delete('XscriptPropsWithHighlight')
 endfunc
 
+func Test_prop_add_with_text_fails()
+  call prop_type_add('failing', #{highlight: 'ErrorMsg'})
+  call assert_fails("call prop_add(1, 0, #{type: 'failing', text: 'X', end_lnum: 1})", 'E1305:')
+  call assert_fails("call prop_add(1, 0, #{type: 'failing', text: 'X', end_col: 1})", 'E1305:')
+  call assert_fails("call prop_add(1, 0, #{type: 'failing', text: 'X', length: 1})", 'E1305:')
+
+  call prop_type_delete('failing')
+endfunc
+
 func Test_props_with_text_right_align_twice()
   CheckRunVimInTerminal
 
   let lines =<< trim END
       call setline(1, ["some text some text some text some text", 'line two'])
-      call prop_type_add('MyErrorText', #{ highlight: 'ErrorMsg'})
-      call prop_type_add('MyPadding', #{ highlight: 'DiffChange'})
+      call prop_type_add('MyErrorText', #{highlight: 'ErrorMsg'})
+      call prop_type_add('MyPadding', #{highlight: 'DiffChange'})
       call prop_add(1, 0, #{type: 'MyPadding', text: ' nothing here', text_wrap: 'wrap'})
       call prop_add(1, 0, #{type: 'MyErrorText', text: 'Some error', text_wrap: 'wrap', text_align: 'right'})
       call prop_add(1, 0, #{type: 'MyErrorText', text: 'Another error', text_wrap: 'wrap', text_align: 'right'})
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -488,6 +488,14 @@ prop_add_common(
 
     if (dict_has_key(dict, "text"))
     {
+	if (dict_has_key(dict, "length")
+		|| dict_has_key(dict, "end_col")
+		|| dict_has_key(dict, "end_lnum"))
+	{
+	    emsg(_(e_cannot_use_length_endcol_and_endlnum_with_text));
+	    goto theend;
+	}
+
 	text = dict_get_string(dict, "text", TRUE);
 	if (text == NULL)
 	    goto theend;
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    489,
+/**/
     488,
 /**/
     487,