Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4925,12 +4925,15 @@ private static string RebuildPathWithVars(

for (int i = 0; i < path.Length; i++)
{
// on Windows, we need to preserve the expanded home path as native commands don't understand it
#if UNIX
if (i == homeIndex)
{
_ = sb.Append('~');
i += homePath.Length - 1;
continue;
}
#endif

EscapeCharIfNeeded(sb, path, i, stringType, literalPath, useSingleQuoteEscapeRules, ref quotesAreNeeded);
_ = sb.Append(path[i]);
Expand Down
8 changes: 6 additions & 2 deletions test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1409,12 +1409,16 @@ class InheritedClassTest : System.Attribute
$res.CompletionMatches[0].CompletionText | Should -Be "`"$expectedPath`""
}

It "Should keep '~' in completiontext when it's used to refer to home in input" {
It "Should handle '~' in completiontext when it's used to refer to home in input" {
$res = TabExpansion2 -inputScript "~$separator"
# select the first answer which does not have a space in the completion (those completions look like & '3D Objects')
$observedResult = $res.CompletionMatches.Where({$_.CompletionText.IndexOf("&") -eq -1})[0].CompletionText
$completedText = $res.CompletionMatches.CompletionText -join ","
$observedResult | Should -BeLike "~$separator*" -Because "$completedText"
if ($IsWindows) {
$observedResult | Should -BeLike "$home$separator*" -Because "$completedText"
} else {
$observedResult | Should -BeLike "~$separator*" -Because "$completedText"
}
}

It "Should use '~' as relative filter text when not followed by separator" {
Expand Down