escape_code_length: test all setaf parameters

Taking a different approach here. I can't see why we'd only want to
recognize certain colors. Now, we'll just try all the colors fish might
use.

This could probably be optimized now that there are more
than 8 (or 16) colors fish can do.
This commit is contained in:
Aaron Gyes 2016-10-10 11:56:25 -07:00
parent ea3e144f2d
commit f464704884

View file

@ -205,7 +205,7 @@ size_t escape_code_length(const wchar_t *code) {
bool found = false;
if (cur_term != NULL) {
// Detect these terminfo color escapes with parameter value 0..16, all of which don't move
// Detect these terminfo color escapes with parameter value up to max_colors-1, all of which don't move
// the cursor.
char *const esc[] = {
set_a_foreground, set_a_background, set_foreground, set_background,
@ -214,7 +214,7 @@ size_t escape_code_length(const wchar_t *code) {
for (size_t p = 0; p < sizeof esc / sizeof *esc && !found; p++) {
if (!esc[p]) continue;
for (size_t k = 0; k < std::min(16UL, static_cast<size_t>(max_colors)); k++) {
for (int k = 0; k < (max_colors - 1); k++) {
size_t len = try_sequence(tparm(esc[p], k), code);
if (len) {
resulting_length = len;