# HG changeset patch # User Bram Moolenaar # Date 1676840403 -3600 # Node ID a509eb37a813a8ef1e0d06e8a0a6f915aff80f6a # Parent 19571fecac05a5fc7ed2e0bdd778948744354899 patch 9.0.1328: error when using "none" for GUI color is confusing Commit: https://github.com/vim/vim/commit/5b9f57262fdadf460e6355abf1eee95b4f96abe8 Author: Bram Moolenaar Date: Sun Feb 19 20:49:38 2023 +0000 patch 9.0.1328: error when using "none" for GUI color is confusing Problem: Error when using "none" for GUI color is confusing. Solution: Mention that the name should perhaps be "NONE". (closes https://github.com/vim/vim/issues/1400) diff --git a/src/errors.h b/src/errors.h --- a/src/errors.h +++ b/src/errors.h @@ -3447,3 +3447,5 @@ EXTERN char e_cannot_define_new_function 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\"?")); diff --git a/src/gui.c b/src/gui.c --- 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; } diff --git a/src/testdir/test_highlight.vim b/src/testdir/test_highlight.vim --- a/src/testdir/test_highlight.vim +++ b/src/testdir/test_highlight.vim @@ -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) diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -696,6 +696,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1328, +/**/ 1327, /**/ 1326,