From: Ben Knoble Date: Mon, 19 Oct 2026 19:56:18 GMT Subject: Re: [PATCH 3/5] completion: fix Zsh handling of stash names Message-ID: <841E7396-646B-4667-84C8-A51BDD7371F2@gmail.com> In-Reply-To: > Le 16 oct. 2026 à 04:01, Patrick Steinhardt a écrit : > > On Mon, Oct 12, 2026 at 01:48:29PM -0400, D. Ben Knoble wrote: >> When Git completes stashes for Zsh, it eventually invokes something like >> this (via our redefinition of __gitcomp_nl): >> >> compadd -Q -S " " -p "" -- 'stash@{0}' 'stash@{1}' && _ret=0 >> >> Because of -Q, the braces are unquoted, and Zsh will leave us at (for >> example) >> >> git stash show stash@{ >> cursor ^ >> >> From here, the list-choices widget (on Ctrl-D by default) will show >> stash@{0} and stash@{1}, but the complete-word widget (Tab) will just >> add another brace. Zsh things we're trying to do a brace expansion, I > > s/things/thinks/ Will fix! >> think! Interestingly, using menu-complete (Ctrl-N) does cycle through >> matches, since it's taking a slightly different completion path in Zsh. >> >> We might try to fix this by passing surrounding single quotes (using the >> -S/-p arguments of compadd, which we can do via __gitcomp_nl's other >> parameters), and indeed Zsh will generate >> >> git stash show 'stash@{ >> cursor ^ >> >> but completing here won't find anything, and I'm not totally sure why. >> >> Instead, though, we can let Zsh quote metacharacters (removing -Q) and >> everything "just works." It changes the output format a bit (users see >> stash@\{0\}, for example), but I find this an improvement over not being >> able to complete names at all. menu-complete is unchanged aside from the >> extra backslashes. >> >> So, override stash listing completion in Zsh with a working version. > > Hm. I assume you tried finding a variant that works for both Bash and > Zsh so that we don't have to carry this override? Actually, no. I assumed Bash was working and haven’t tested it either way. Presumably we’d have a report from someone if it were doing what Zsh does? Many Zsh users, OTOH, use the Zsh-distributed completions, which stackoverflow for me (and anyway I prefer ours). I won’t have time to see if Bash is also Brien here, but this shouldn’t change Bash’s behavior at least. Oh, re-reading: yes, I looked for something that was compatible with existing code. I mentioned one such attempt (single quotes). No luck, though.