--- rxvt-unicode/src/command.C 2016/06/30 16:59:02 1.576 +++ rxvt-unicode/src/command.C 2016/06/30 17:03:45 1.579 @@ -3367,9 +3367,6 @@ unsigned int idx_b = b * (Blue_levels - 1) / 0xff; unsigned int idx = colorcube_index (idx_r, idx_g, idx_b); - if (rgb24_color[idx] == color) - return idx + minTermCOLOR24; - /* we allow one of the 6 directly neighbouring colours */ /* to replace the current color, if they not used recently */ static const signed char dxyz[][3] = { @@ -3388,17 +3385,18 @@ int g = idx_r + dxyz[n][1]; int b = idx_r + dxyz[n][2]; - if (!IN_RANGE_EXC (r, 0, Red_levels)) - continue; - - if (!IN_RANGE_EXC (g, 0, Green_levels)) - continue; - - if (!IN_RANGE_EXC (b, 0, Blue_levels)) - continue; + if (!IN_RANGE_EXC (r, 0, Red_levels )) continue; + if (!IN_RANGE_EXC (g, 0, Green_levels)) continue; + if (!IN_RANGE_EXC (b, 0, Blue_levels )) continue; unsigned int index = colorcube_index (r, g, b); + if (rgb24_color[index] == color) + { + rgb24_seqno[index] = ++rgb24_sequence; + return index + minTermCOLOR24; + } + // minor issue: could update index 0 few more times if ((rgb24_seqno[index] | rgb24_color[index]) == 0) { @@ -3406,9 +3404,6 @@ goto update; } - if (rgb24_color[index] == color) - return index + minTermCOLOR24; - // like (rgb24_seqno[idx] > rgb24_seqno[index]) // but also handles wrap around values good enough if ((uint16_t)(rgb24_seqno[idx] - rgb24_seqno[index]) < 0x7fff)