carapace-sh / carapace

command argument completion generator for spf13/cobra
https://carapace.sh
Apache License 2.0
436 stars 11 forks source link

Completions Contain Trailing space #1051

Closed Karuption closed 4 weeks ago

Karuption commented 1 month ago

Current Behavior

When doing a completion, there is a trailing space.

Expected Behavior

Native completions do not include a space in powershell, even on flag completions. I would expect carapace to be idiomatic with these.

Steps To Reproduce

  1. In windows 10, using Terminal
  2. My $PROFILE:

    Import-Module PSFzf
    Set-PSReadLineKeyHandler -Key Tab -ScriptBlock { Invoke-FzfTabCompletion }
    
    $env:CARAPACE_BRIDGES = 'zsh,fish,bash,inshellisense' # optional
    carapace _carapace | Out-String | Invoke-Expression
  3. Type gh a <TAB>
  4. Select Alias from the FZF window
  5. Auto completion of gh "alias "

Version

1.0.7

OS

Shell

Anything else?

I can see that the json generated by carapace gh powershell a has a trailing space in its CompletionText. Since there is a char in the string that needs to be escaped, FZF puts quotes around it for a literal.

The trailing space is visible by doing:

carapace.exe gh powershell a  | ConvertFrom-Json | Select-Object -First 1 -ExpandProperty CompletionText  | Select-String -Pattern .*

This functionality seems like it is intentional, but I am not able to find exactly where in the code (or spec) that this is happening. A configuration option to disable or set the trailing options would be amazing.

Polar

Fund with Polar

rsteube commented 4 weeks ago

Yes, this is an intentional feature for fluent completion and one of the things powershell doesn't do well. I can understand though how the inconsistency can be disrupting and adding this is fairly easy.

Karuption commented 4 weeks ago

Thank you! Looking forward to the next release.