From: dana <dana@dana.is>
To: zsh-workers@zsh.org
Subject: [PATCH] Fix rendering bug in completion formatter
Date: Sun, 24 Dec 2017 16:21:06 -0600 [thread overview]
Message-ID: <C005FA23-A9B5-46A9-8EF4-6751BBECBCB0@dana.is> (raw)
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'
reply other threads:[~2017-12-24 22:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=C005FA23-A9B5-46A9-8EF4-6751BBECBCB0@dana.is \
--to=dana@dana.is \
--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).