Mercurial > vim
comparison src/highlight.c @ 26115:bb87ce13e7d6 v8.2.3590
patch 8.2.3590: test for v:colornames sometimes fails
Commit: https://github.com/vim/vim/commit/a0fca17251bf491db7b8d302ce22dee844597e82
Author: Drew Vogel <dvogel@github>
Date: Sat Nov 13 10:50:01 2021 +0000
patch 8.2.3590: test for v:colornames sometimes fails
Problem: Test for v:colornames sometimes fails. (Dominique Pell?)
Solution: Check features. Clear v:colornames between tests. (Drew Vogel,
closes #9105, closes #9073)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 13 Nov 2021 12:00:03 +0100 |
parents | c544eacaf066 |
children | 3da380450cce |
comparison
equal
deleted
inserted
replaced
26114:32f4ca8378c3 | 26115:bb87ce13e7d6 |
---|---|
2330 } | 2330 } |
2331 | 2331 |
2332 return INVALCOLOR; | 2332 return INVALCOLOR; |
2333 } | 2333 } |
2334 | 2334 |
2335 // Maps the given name to the given color value, overwriting any current | |
2336 // mapping. If allocation fails the named color will no longer exist in the | |
2337 // table and the user will receive an error message. | |
2338 void | |
2339 save_colorname_hexstr(int r, int g, int b, char_u *name) | |
2340 { | |
2341 int result; | |
2342 dict_T *colornames_table; | |
2343 dictitem_T *existing; | |
2344 char_u hexstr[8]; | |
2345 | |
2346 if (vim_snprintf((char *)hexstr, sizeof(hexstr), | |
2347 "#%02x%02x%02x", r, g, b) < 0) | |
2348 { | |
2349 semsg(_(e_cannot_allocate_color_str), name); | |
2350 return; | |
2351 } | |
2352 | |
2353 colornames_table = get_vim_var_dict(VV_COLORNAMES); | |
2354 // The colornames_table dict is safe to use here because it is allocated at | |
2355 // startup in evalvars.c | |
2356 existing = dict_find(colornames_table, name, -1); | |
2357 if (existing != NULL) | |
2358 { | |
2359 dictitem_remove(colornames_table, existing); | |
2360 existing = NULL; // dictitem_remove freed the item | |
2361 } | |
2362 | |
2363 result = dict_add_string(colornames_table, (char *)name, hexstr); | |
2364 if (result == FAIL) | |
2365 semsg(_(e_cannot_allocate_color_str), name); | |
2366 } | |
2367 | |
2368 /* | 2335 /* |
2369 * Load a default color list. Intended to support legacy color names but allows | 2336 * Load a default color list. Intended to support legacy color names but allows |
2370 * the user to override the color values. Only loaded once. | 2337 * the user to override the color values. Only loaded once. |
2371 */ | 2338 */ |
2372 void | 2339 void |