diff --git a/src/rcfile.c b/src/rcfile.c index f52bc45c..062fba55 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -991,10 +991,11 @@ void parse_includes(char *ptr) } /* Return the index of the color that is closest to the given RGB levels, - * assuming that the terminal uses the 6x6x6 color cube of xterm-256color. */ + * assuming that the terminal uses the 6x6x6 color cube of xterm-256color. + * When red == green == blue, return an index in the xterm gray scale. */ short closest_index_color(short red, short green, short blue) { - /* Translation table, from 16 intended levels to 6 available levels. */ + /* Translation table, from 16 intended color levels to 6 available levels. */ static const short level[] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 }; /* Translation table, from 14 intended gray levels to 24 available levels. */ @@ -1002,7 +1003,7 @@ short closest_index_color(short red, short green, short blue) if (COLORS != 256) return THE_DEFAULT; - else if (red == green && red == blue && red > 0 && red < 0xF) + else if (red == green && green == blue && 0 < red && red < 0xF) return 232 + gray[red - 1]; else return (36 * level[red] + 6 * level[green] + level[blue] + 16);