* [PATCH] Fix rendering bug in completion formatter
@ 2017-12-24 22:21 dana
0 siblings, 0 replies; only message in thread
From: dana @ 2017-12-24 22:21 UTC (permalink / raw)
To: zsh-workers
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'
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2017-12-24 22:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-24 22:21 [PATCH] Fix rendering bug in completion formatter dana
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).