Repository navigation
fix(completion): fall back to shell path completion - #15442
Conversation
c5ea955 to
53d4f22
Compare
ElectreAAS
left a comment
There was a problem hiding this comment.
Aside from my comments, I tested this with bash and zsh and it works :)
41b7075 to
b1434f5
Compare
|
Unfortunately @shonfeder @ElectreAAS any thoughts? I'll mark as draft until we sort this out. We could also defer looking into it for later. |
b1434f5 to
e26e23f
Compare
I was going to ask what versions specifically, to check how old they were, but gnu.org is down so I can't even check. Incredible. |
e26e23f to
bfc37ae
Compare
It seems to be supported from version 3.0 of bash, which is at least 20 years old ? |
|
I think it's ok to expect a bash updated in the last 20 years if you want completion? @Alizter do you have a system where the completion is not working? Or what led you to think this would be a problem for users? That said, it's only worth adding this flag if generally makes things better for users. Better to drop it if not, of course. |
The bash version that ships with macOS appears to be old due to the license change in bash 4.0 to GPLv3. I don't think its sensible supporting such an old version of bash, users on macos would be using zsh anyway.
No, our bash completion tests were running on macos which used its default ancient bash. The solution is just to run on linux only. I'll add the |
bfc37ae to
89ea680
Compare
When cmdliner has no semantic completions to offer, let Dune completion scripts fall back to the shell normal filename completion instead of suppressing completion entirely. Bash registers the generated completer with -o bashdefault and -o default. Zsh and PowerShell keep the cmdliner-generated completers unchanged under internal names, then expose Dune-owned wrappers that delegate to shell filename completion when cmdliner returns no matches. Tests: - ./dune.exe fmt - ./dune.exe runtest test/blackbox-tests/test-cases/completion/commands.t test/blackbox-tests/test-cases/completion/bash.t - nix develop path:. -i -c ./dune.exe runtest test/blackbox-tests/test-cases/completion/commands.t test/blackbox-tests/test-cases/completion/bash.t - ./dune.exe build @check - manual zsh probe via nix run nixpkgs#zsh: confirmed the generated wrapper reaches _default for a runtest path prefix - manual PowerShell probe via nix run nixpkgs#powershell: confirmed TabExpansion2 returns completion/commands.t for a runtest path prefix Signed-off-by: Ali Caglayan <[email protected]>
89ea680 to
89211c9
Compare
Description
Allow generated shell completion scripts to fall back to the shell's normal filename completion when cmdliner has no semantic completions to offer.
For bash, Dune now registers completion with
-o default. For zsh and PowerShell, Dune keeps the cmdliner-generated completers unchanged under internal names and exposes small Dune-owned wrappers that fall back to the shell filename completer only when cmdliner returns no matches.Related Issue and Motivation
Since #14779 moved completion script handling to cmdliner, commands such as
dune runtest ...no longer fell through to normal path completion when Dune had no completions to return. This restores the expected shell fallback behavior.Fixes #15431
Shell fallback references
complete -o defaultas using Readline default filename completion when the compspec generates no matches: https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html_defaultfor the-default-completion context, andcompstate[nmatches]as the number of matches added so far: https://zsh.sourceforge.io/Doc/Release/Completion-System.html and https://zsh.sourceforge.io/Doc/Release/Completion-Widgets.htmlRegister-ArgumentCompleter -Nativescriptblocks return completion values, and PowerShell's own completion code falls back toCompletionCompleters.CompleteFilename(...)when no argument completions are found: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/register-argumentcompleter and https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.csChecklist