+15
-7
lines changedFilter options
+15
-7
lines changed Original file line number Diff line number Diff line change
@@ -124,6 +124,10 @@ Dictionary nvim__get_hl_defs(Integer ns_id, Error *err)
124
124
125
125
/// Set a highlight group.
126
126
///
127
+
/// Note: unlike the `:highlight` command which can update a highlight group,
128
+
/// this function completely replaces the definition. For example:
129
+
/// `nvim_set_hl(0, 'Visual', {})` will clear the highlight group 'Visual'.
130
+
///
127
131
/// @param ns_id number of namespace for this highlight. Use value 0
128
132
/// to set a highlight group in the global (`:highlight`)
129
133
/// namespace.
Original file line number Diff line number Diff line change
@@ -927,10 +927,11 @@ int object_to_color(Object val, char *key, bool rgb, Error *err)
927
927
} else if (val.type == kObjectTypeString) {
928
928
String str = val.data.string;
929
929
// TODO(bfredl): be more fancy with "bg", "fg" etc
930
+
if (!str.size || STRICMP(str.data, "NONE") == 0) {
931
+
return -1;
932
+
}
930
933
int color;
931
-
if (!str.size) {
932
-
color = 0;
933
-
} else if (rgb) {
934
+
if (rgb) {
934
935
color = name_to_color(str.data);
935
936
} else {
936
937
color = name_to_ctermcolor(str.data);
Original file line number Diff line number Diff line change
@@ -304,10 +304,6 @@ describe("API: set highlight", function()
304
304
eq('Test_hl3 xxx ctermbg=9',
305
305
exec_capture('highlight Test_hl3'))
306
306
307
-
meths.set_hl(0, 'Test_hl3', {})
308
-
eq('Test_hl3 xxx cleared',
309
-
exec_capture('highlight Test_hl3'))
310
-
311
307
eq("'redd' is not a valid color",
312
308
pcall_err(meths.set_hl, 0, 'Test_hl3', {fg='redd'}))
313
309
@@ -320,5 +316,12 @@ describe("API: set highlight", function()
320
316
321
317
eq("'#FF00FF' is not a valid color",
322
318
pcall_err(meths.set_hl, 0, 'Test_hl3', {ctermfg='#FF00FF'}))
319
+
320
+
for _, fg_val in ipairs{ nil, 'NONE', 'nOnE', '', -1 } do
321
+
meths.set_hl(0, 'Test_hl3', {fg = fg_val})
322
+
eq('Test_hl3 xxx cleared',
323
+
exec_capture('highlight Test_hl3'))
324
+
end
325
+
323
326
end)
324
327
end)
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4