zsh-workers
 help / color / mirror / code / Atom feed
From: dana <dana@dana.is>
To: Jan Larres <jan@majutsushi.net>
Cc: zsh-workers@zsh.org
Subject: Re: Small zle_highlight regression in 5.7
Date: Thu, 31 Jan 2019 19:46:33 -0600	[thread overview]
Message-ID: <7CC43B0E-687B-4C5A-9306-92F05C431406@dana.is> (raw)
In-Reply-To: <6e542e69-1e09-1af7-0c68-8af456dd043e@majutsushi.net>

On 31 Jan 2019, at 17:31, Jan Larres <jan@majutsushi.net> 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


  reply	other threads:[~2019-02-01  1:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-31 23:31 Jan Larres
2019-02-01  1:46 ` dana [this message]
2019-02-01  3:40   ` Jan Larres

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7CC43B0E-687B-4C5A-9306-92F05C431406@dana.is \
    --to=dana@dana.is \
    --cc=jan@majutsushi.net \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).