]> granicus.if.org Git - vim/commitdiff
patch 8.1.0588: cannot define a sign with space in the text v8.1.0588
authorBram Moolenaar <Bram@vim.org>
Fri, 14 Dec 2018 18:37:08 +0000 (19:37 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 14 Dec 2018 18:37:08 +0000 (19:37 +0100)
Problem:    Cannot define a sign with space in the text.
Solution:   Allow for escaping characters. (Ben Jackson, closes #2967)

src/ex_cmds.c
src/testdir/test_signs.vim
src/version.c

index cb728d4052f0a9ea307731212214750b7bcf45ad..cd243a5ef4167189947a9e298c0383d134d21096 100644 (file)
@@ -7779,6 +7779,14 @@ ex_sign(exarg_T *eap)
                        int     len;
 
                        arg += 5;
+                       for (s = arg; s + 1 < p; ++s)
+                           if (*s == '\\')
+                           {
+                               // Remove a backslash, so that it is possible
+                               // to use a space.
+                               STRMOVE(s, s + 1);
+                               --p;
+                           }
 # ifdef FEAT_MBYTE
                        /* Count cells and check for non-printable chars */
                        if (has_mbyte)
index a9674353462e203b100334ca37c69ab73d090714..96e0244fedc7d27a72f3e3c10554c487f6841737 100644 (file)
@@ -104,6 +104,33 @@ func Test_sign()
   exe 'sign jump 43 file=' . fn
   call assert_equal('B', getline('.'))
 
+  " can't define a sign with a non-printable character as text
+  call assert_fails("sign define Sign4 text=\e linehl=Comment", 'E239:')
+  call assert_fails("sign define Sign4 text=a\e linehl=Comment", 'E239:')
+  call assert_fails("sign define Sign4 text=\ea linehl=Comment", 'E239:')
+
+  " Only 1 or 2 character text is allowed
+  call assert_fails("sign define Sign4 text=abc linehl=Comment", 'E239:')
+  call assert_fails("sign define Sign4 text= linehl=Comment", 'E239:')
+  call assert_fails("sign define Sign4 text=\ ab  linehl=Comment", 'E239:')
+
+  " define sign with whitespace
+  sign define Sign4 text=\ X linehl=Comment
+  sign undefine Sign4
+  sign define Sign4 linehl=Comment text=\ X
+  sign undefine Sign4
+
+  sign define Sign5 text=X\  linehl=Comment
+  sign undefine Sign5
+  sign define Sign5 linehl=Comment text=X\ 
+  sign undefine Sign5
+
+  " define sign with backslash
+  sign define Sign4 text=\\\\ linehl=Comment
+  sign undefine Sign4
+  sign define Sign4 text=\\ linehl=Comment
+  sign undefine Sign4
+
   " After undefining the sign, we should no longer be able to place it.
   sign undefine Sign1
   sign undefine Sign2
index cc609967a234014c37538f4e7bc623663cc9d827..3c9eb0d8849ac0137e81a6e26deca26b1802e6f0 100644 (file)
@@ -799,6 +799,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    588,
 /**/
     587,
 /**/