]> granicus.if.org Git - vim/commitdiff
patch 9.0.1328: error when using "none" for GUI color is confusing v9.0.1328
authorBram Moolenaar <Bram@vim.org>
Sun, 19 Feb 2023 20:49:38 +0000 (20:49 +0000)
committerBram Moolenaar <Bram@vim.org>
Sun, 19 Feb 2023 20:49:38 +0000 (20:49 +0000)
Problem:    Error when using "none" for GUI color is confusing.
Solution:   Mention that the name should perhaps be "NONE". (closes #1400)

src/errors.h
src/gui.c
src/testdir/test_highlight.vim
src/version.c

index 0bfafac1f16d452d4834dfd776dff3b8aa9b0efc..a5df8edcd71f079281dda028024657a2fc4c108f 100644 (file)
@@ -3447,3 +3447,5 @@ EXTERN char e_cannot_define_new_function_in_abstract_class[]
 EXTERN char e_using_null_object[]
        INIT(= N_("E1360: Using a null object"));
 #endif
+EXTERN char e_cannot_use_color_none_did_you_mean_none[]
+       INIT(= N_("E1361: Cannot use color \"none\", did you mean \"NONE\"?"));
index b8910054b0e5d36ca229b74141e8b8f2d614a499..0e005478a961ace802ddbce26ca54fe1cc2e81a4 100644 (file)
--- a/src/gui.c
+++ b/src/gui.c
@@ -4634,12 +4634,18 @@ gui_get_color(char_u *name)
        return INVALCOLOR;
     t = gui_mch_get_color(name);
 
+    int is_none = STRCMP(name, "none") == 0;
     if (t == INVALCOLOR
 #if defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
-           && gui.in_use
+           && (gui.in_use || is_none)
 #endif
            )
-       semsg(_(e_cannot_allocate_color_str), name);
+    {
+       if (is_none)
+           emsg(_(e_cannot_use_color_none_did_you_mean_none));
+       else
+           semsg(_(e_cannot_allocate_color_str), name);
+    }
     return t;
 }
 
index 26426e05cb508b95b39d42f346fe1ba89e80b66d..feccf84b6cd331c6006881a2974eb0f0fb8e98ae 100644 (file)
@@ -46,6 +46,10 @@ func Test_highlight()
   call assert_equal("Group3         xxx cleared",
                                \ split(execute("hi Group3"), "\n")[0])
   call assert_fails("hi Crash term='asdf", "E475:")
+
+  if has('gui_running')
+    call assert_fails('hi NotUsed guibg=none', 'E1361:')
+  endif
 endfunc
 
 func HighlightArgs(name)
index f8b75d74d88cb19519d6404e74a1bc52d1aa438c..41726ea3e4986bcc00ed39eef752f9cd8c3d4f3a 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1328,
 /**/
     1327,
 /**/