summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2025-11-17 04:32:05 +0100
committerOliver Kiddle <opk@zsh.org>2025-11-17 04:32:05 +0100
commitec29b4c137f79f525267b56879be206eebda5639 (patch)
tree0610faccd4cd92935877f0cfbde88de838bd11c8
parent54034: ignore completer filenames with funny characters in them (diff)
downloadzsh-ec29b4c137f79f525267b56879be206eebda5639.tar
zsh-ec29b4c137f79f525267b56879be206eebda5639.tar.gz
zsh-ec29b4c137f79f525267b56879be206eebda5639.tar.bz2
zsh-ec29b4c137f79f525267b56879be206eebda5639.tar.lz
zsh-ec29b4c137f79f525267b56879be206eebda5639.tar.xz
zsh-ec29b4c137f79f525267b56879be206eebda5639.tar.zst
zsh-ec29b4c137f79f525267b56879be206eebda5639.zip
54075: allow highlighting to be reset in prompts using %H without following braces
-rw-r--r--ChangeLog4
-rw-r--r--Doc/Zsh/prompt.yo1
-rw-r--r--Src/Modules/watch.c3
-rw-r--r--Src/Zle/complist.c4
-rw-r--r--Src/Zle/zle_tricky.c3
-rw-r--r--Src/prompt.c10
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 <opk@zsh.org>
+ * 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 '[':