Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Small zle_highlight regression in 5.7



Odd, I wonder where I got the idea that 'reset' was the correct thing to use then. I think that's some old relic that I haven't really looked at in years. I also missed the mention of 'default' somehow. Using 'default' does make it work for me though, so thanks!

-Jan


On 01/02/2019 14:46, dana wrote:
On 31 Jan 2019, at 17:31, Jan Larres <jan@xxxxxxxxxxxxxx> wrote:
In 5.6.2 I was able to use the special 'reset' foreground attribute ...
This doesn't work any more in 5.7: ...
I also can't find any mention of this attribute in the documentation any more.

I don't think it was ever there — the documented way to do this is %F{default}
or simply %f. %F{reset} only worked because unrecognised colour names would
just fall back to the default sequence (which doesn't seem to be mentioned
explicitly anywhere?).

5.7 did change that, though, and i'm not sure it was intended.

This seems to fix it

dana


diff --git a/Src/prompt.c b/Src/prompt.c
index 4603ffba6..f2b3f161e 100644
--- a/Src/prompt.c
+++ b/Src/prompt.c
@@ -1661,10 +1661,12 @@ match_colour(const char **teststrp, int is_fg, int colour)
  	    colour = match_named_colour(teststrp);
  	    if (colour == 8) {
  		/* default */
  		return is_fg ? TXTNOFGCOLOUR : TXTNOBGCOLOUR;
  	    }
+	    if (colour < 0)
+		return TXT_ERROR;
  	}
  	else {
  	    colour = (int)zstrtol(*teststrp, (char **)teststrp, 10);
  	    if (colour < 0 || colour >= 256)
  		return TXT_ERROR;

diff --git a/Test/D01prompt.ztst b/Test/D01prompt.ztst
index 56b7c294a..7ff478e68 100644
--- a/Test/D01prompt.ztst
+++ b/Test/D01prompt.ztst
@@ -221,3 +221,11 @@
    print ${(%U)Y-%(v}
  0:Regression test for test on empty psvar
  >
+
+# Unrecognised colour strings should produce the default sequence
+  f=${(%):-'%f'} # Recognised
+  Fdefault=${(%):-'%F{default}'} # Recognised
+  Freset=${(%):-'%F{reset}'} # Unrecognised
+  Ffoo=${(%):-'%F{foo}'} # Unrecognised
+  [[ $f == $Fdefault && $Fdefault == $Freset && $Freset == $Ffoo ]]
+0:Regression test for workers/44029




Messages sorted by: Reverse Date, Date, Thread, Author