Skip to content

Broken tab-completion with file or directory names with spaces in the context of tilde-prefixed paths (~) #20851

@mklement0

Description

@mklement0

Prerequisites

Steps to reproduce

Note:

The solution is the same on both platforms: preserve the unquoted status of an initial ~ if specified as such.

$null = New-Item -Force "$HOME/a test"

(TabExpansion2 'code ~/a').CompletionMatches[0].CompletionText
(TabExpansion2 'code ~/''a').CompletionMatches[0].CompletionText
(TabExpansion2 'code ~/"a').CompletionMatches[0].CompletionText

# Remove-Item "$HOME/a test" # clean up

Related:

Expected behavior

~/'a test'
~/'a test'
~/"a test"

That is, the unquoted status of the initial ~ should be preserved.

Actual behavior

'~/a test'
'~/a test'
'~/a test'

That is, all expansions resulted in inappropriate quoting in that the previously unquoted ~ - required to trigger PowerShell's tilde-expansion emulation when calling external programs - is now quoted.

Error details

No response

Environment data

PowerShell 7.4.0 on Unix-like platforms.

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs-TriageThe issue is new and needs to be triaged by a work group.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions