dahlbyk / posh-git

A PowerShell environment for Git
http://dahlbyk.github.io/posh-git/
MIT License
7.62k stars 802 forks source link

No space added after auto-completion when using posh-git #964

Open penguineer opened 10 months ago

penguineer commented 10 months ago

System Details

Issue Description

I've noticed that a space is not being added after auto-completion. This behavior is different from the default PowerShell behavior and bash behavior, where a space is typically added after auto-completion and is causing some inconvenience as I have to manually add a space.

Here's the configuration I'm using:

Import-Module posh-git

Register-ArgumentCompleter -Native -CommandName az -ScriptBlock {
    param($commandName, $wordToComplete, $cursorPosition)
    $completion_file = New-TemporaryFile
    $env:ARGCOMPLETE_USE_TEMPFILES = 1
    $env:_ARGCOMPLETE_STDOUT_FILENAME = $completion_file
    $env:COMP_LINE = $wordToComplete
    $env:COMP_POINT = $cursorPosition
    $env:_ARGCOMPLETE = 1
    $env:_ARGCOMPLETE_SUPPRESS_SPACE = 0
    $env:_ARGCOMPLETE_IFS = "`n"
    $env:_ARGCOMPLETE_SHELL = 'powershell'
    az 2>&1 | Out-Null
    Get-Content $completion_file | Sort-Object | ForEach-Object {
        [System.Management.Automation.CompletionResult]::new($_, $_, "ParameterValue", $_)
    }
    Remove-Item $completion_file, Env:\_ARGCOMPLETE_STDOUT_FILENAME, Env:\ARGCOMPLETE_USE_TEMPFILES, Env:\COMP_LINE, Env:\COMP_POINT, Env:\_ARGCOMPLETE, Env:\_ARGCOMPLETE_SUPPRESS_SPACE, Env:\_ARGCOMPLETE_IFS, Env:\_ARGCOMPLETE_SHELL
}

Set-PSReadlineKeyHandler -Key Tab -Function Complete

Write-Host "Profile reloaded at $(Get-Date)"

I've tried disabling everything except the posh-git module and resetting my PowerShell settings to their defaults, but the issue persists. I'm not sure if this is a bug in posh-git or if there's a conflict with my configuration.

Any help would be appreciated. Thanks!