From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29417 invoked by alias); 24 Dec 2017 22:21:14 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42164 Received: (qmail 15306 invoked by uid 1010); 24 Dec 2017 22:21:14 -0000 X-Qmail-Scanner-Diagnostics: from mail-it0-f44.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.214.44):SA:0(-1.9/5.0):. Processed in 2.415631 secs); 24 Dec 2017 22:21:14 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: dana@dana.is X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:content-transfer-encoding:mime-version :subject:message-id:date:to; bh=FQHspx7BQ/zQ8Ay0OauygpU7ZuDnLort6NsVqFPHGrE=; b=elweAtVMNE45VhPTGNOTwht9rH+hzp/dEnUwd8SU0p7KHmnUsv8hme7FcJYRv0oi8l XyXqy55iwPpc2Tqizf0d7VculAdgmuPHH7xCh8k5wXTFIQe3aea1DkgwicdAB6KFHXSh bC5Wttir8QtHJIsaUwKoaypakRJI2IFGLStZ1Jud23f7r07tviLfUUKVxWrWxB0dvDxy PSxoXtDE7lv7ydGcOEEsLrRjKxvmU29Cal1f0yWEICdE4E5ibP+r4duHVGmBEz8Bf++S ZkDxWmTnblZfE2DnaoAD6euUi+WFVOAOM7G1PqBlHFbAgTldZILWaBjMhq+Mrj5BK+pJ KjCA== X-Gm-Message-State: AKGB3mLGiH9RWKfXz0wq6/E8sKA1myY3SYGiiCWU9qyipc35R41VC1+I 2AiWl/dwPMvZvpKzTOO7eAGNr5Ta9nA= X-Google-Smtp-Source: ACJfBovRE4yOllHENbL16oFSwYVKAXRr0/Wka/sbQKfg3jwmRb+nNTVMeQQm0ObOulsr37L2wHNLQQ== X-Received: by 10.36.121.130 with SMTP id z124mr28276560itc.25.1514154068428; Sun, 24 Dec 2017 14:21:08 -0800 (PST) From: dana Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [PATCH] Fix rendering bug in completion formatter Message-Id: Date: Sun, 24 Dec 2017 16:21:06 -0600 To: zsh-workers@zsh.org X-Mailer: Apple Mail (2.3273) 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 - 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 +=3D len; if (*p) { int arg =3D 0, is_fg; =20 + if (idigit(*p)) + arg =3D zstrtol(p, &p, 10); + len =3D MB_METACHARLENCONV(p, &cchar); #ifdef MULTIBYTE_SUPPORT if (cchar =3D=3D WEOF) cchar =3D (wchar_t)(*p =3D=3D Meta ? p[1] ^ 32 : = *p); #endif p +=3D len; =20 - if (idigit(*p)) - arg =3D zstrtol(p, &p, 10); - m =3D 0; switch (cchar) { case ZWC('%'): if (dopr =3D=3D 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} =20 + # 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=3D( $ZTST_srcdir:A )" comptest $'zt\t'