Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Fix rendering bug in completion formatter
- X-seq: zsh-workers 42164
- From: dana <dana@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Fix rendering bug in completion formatter
- Date: Sun, 24 Dec 2017 16:21:06 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=FQHspx7BQ/zQ8Ay0OauygpU7ZuDnLort6NsVqFPHGrE=; b=aXzYjCLDGa0sD9N3X4FRySCKHqyxvZv8f1hn35kufHu42J1mc+3bt6x0pkZD9NGc3W 6+ueMB0bNCBKjNHhuT7u4Z5HxtpUqeUDpgUF6bXvhYDFRFbCHSNg6i1ZdiLzTEJRdZns GjWruKGZuCJY0ii2QF90abi7SEECYt+Z78T1f4duqIw0EidVXd1tx7nIfyp/a3/g1yDI GljD7OPE9/w8HQHztM8bJVCErg6Oe09ck7EPpFFuWk4KNdM0hNVWoXM+1cgl3EsloHGN HUySgs+AvAd1XqcE6wBOxF8hwC9jAhdInJY6od4OUDwb8L+dmVoBF3AlNu/+/6dk/DMD cjGg==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Found a tiny Christmas bug~
The completion formatting code is meant to support the same colour sequences
with %F and %K as in prompt expansion: either in the simple numeric format like
%1F or in the extended format like %F{1} or %F{red}. An error on the completion
side prevents the simple numeric format from working at all, and has the
side-effect of swallowing up any numbers that follow other sequences like %B.
Replication:
% zsh -f
% autoload -Uz compinit && compinit
% zstyle ':completion:*' group-name ''
% zstyle ':completion:*:descriptions' format '%5F123abc%f %5K123abc%k %B123abc%b'
% tr -<TAB>
Broken/before:
F123abc K123abc abc
Expected/after:
123abc 123abc 123abc
There is similar code in zle_tricky.c but it doesn't look like it suffers from
the same issue (i don't actually know how to test it though).
Not sure a regression test is super necessary but i've included that too.
dana
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index a83daeff9..e768aee5d 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -1096,18 +1096,18 @@ compprintfmt(char *fmt, int n, int dopr, int doesc, int ml, int *stop)
p += len;
if (*p) {
int arg = 0, is_fg;
+ if (idigit(*p))
+ arg = zstrtol(p, &p, 10);
+
len = MB_METACHARLENCONV(p, &cchar);
#ifdef MULTIBYTE_SUPPORT
if (cchar == WEOF)
cchar = (wchar_t)(*p == Meta ? p[1] ^ 32 : *p);
#endif
p += len;
- if (idigit(*p))
- arg = zstrtol(p, &p, 10);
-
m = 0;
switch (cchar) {
case ZWC('%'):
if (dopr == 1)
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index 113a45076..b1c0e40e5 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -56,6 +56,21 @@
>FI:{file1}
>FI:{file2}
+ # Temporarily modify format set in comptest
+ comptesteval 'zstyle -s ":completion:*:descriptions" format oldfmt'
+ comptesteval 'zstyle ":completion:*:descriptions" format \
+ ${oldfmt/>*</>%5F123abc%f %B123abc%b<}'
+ comptest $': \t'
+ comptesteval 'zstyle ":completion:*:descriptions" format $oldfmt'
+0:custom description with formatting sequences
+>line: {: }{}
+*>DESCRIPTION:{*123abc*123abc*~*F123*}
+>DI:{dir1}
+>DI:{dir2}
+>FI:{file1}
+>FI:{file2}
+F:regression test workers/42164
+
# Depends on path assignment in comptestinit
comptesteval "path=( $ZTST_srcdir:A )"
comptest $'zt\t'
Messages sorted by:
Reverse Date,
Date,
Thread,
Author