From ec29b4c137f79f525267b56879be206eebda5639 Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Mon, 17 Nov 2025 04:32:05 +0100 Subject: 54075: allow highlighting to be reset in prompts using %H without following braces --- ChangeLog | 4 ++++ Doc/Zsh/prompt.yo | 1 + Src/Modules/watch.c | 3 ++- Src/Zle/complist.c | 4 +++- Src/Zle/zle_tricky.c | 3 ++- Src/prompt.c | 10 ++++++---- 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index e91fa48cd..758604da1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2025-11-17 Oliver Kiddle + * 54075: Doc/Zsh/prompt.yo, Src/Modules/watch.c, Src/Zle/complist.c, + Src/Zle/zle_tricky.c, Src/prompt.c: allow highlighting to be reset + in prompts using %H without following braces + * 54034: Completion/compinit: ignore completer filenames with funny characters in them diff --git a/Doc/Zsh/prompt.yo b/Doc/Zsh/prompt.yo index 9b713ce4a..d68f00826 100644 --- a/Doc/Zsh/prompt.yo +++ b/Doc/Zsh/prompt.yo @@ -256,6 +256,7 @@ braces so, for example tt(%H{error}) will use the highlighting specification for the `error' group. If the key is not found in the associative array then it has no effect. Highlighting specifications are in the same format as for the tt(zle_highlight) parameter. +If the following braces are absent, attributes are reset to the defaults. ) item(tt(%{)...tt(%}))( Include a string as a literal escape sequence. diff --git a/Src/Modules/watch.c b/Src/Modules/watch.c index 0d86142c1..bb27ab9db 100644 --- a/Src/Modules/watch.c +++ b/Src/Modules/watch.c @@ -378,7 +378,8 @@ watchlog2(int inout, WATCH_STRUCT_UTMP *u, char *fmt, int prnt, int fini) fmt = parsehighlight(fmt + 1, '}', &atr, NULL); if (atr && atr != TXT_ERROR) treplaceattrs(atr); - } + } else + treplaceattrs(0); break; case 'K': if (*fmt == '{') { diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c index 4c87c15d7..9c26b6f99 100644 --- a/Src/Zle/complist.c +++ b/Src/Zle/complist.c @@ -1186,7 +1186,9 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop) p = parsehighlight(p + 1, '}', &atr, NULL); if (atr != TXT_ERROR && dopr) treplaceattrs(atr); - } + } else + treplaceattrs(0); + break; case ZWC('{'): if (arg) diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c index f399ebd00..8f32c68e3 100644 --- a/Src/Zle/zle_tricky.c +++ b/Src/Zle/zle_tricky.c @@ -2507,7 +2507,8 @@ printfmt(char *fmt, int n, int dopr, int doesc) --p; if (atr != TXT_ERROR) treplaceattrs(atr); - } + } else + treplaceattrs(0); break; case '{': if (arg) diff --git a/Src/prompt.c b/Src/prompt.c index 83a7667cc..e4e3feb89 100644 --- a/Src/prompt.c +++ b/Src/prompt.c @@ -641,10 +641,12 @@ putpromptchar(int doprint, int endchar) if (bv->fm[1] == '{') { bv->fm = parsehighlight(bv->fm + 2, '}', &atr, NULL); --bv->fm; - if (atr != TXT_ERROR) { - treplaceattrs(atr); - applytextattributes(TSC_PROMPT); - } + } else { + atr = 0; + } + if (atr != TXT_ERROR) { + treplaceattrs(atr); + applytextattributes(TSC_PROMPT); } break; case '[': -- cgit v1.2.3-70-g09d2