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 @@ -442,6 +442,12 @@ internal List<CompletionResult> GetResultHelper(CompletionContext completionCont
result = GetResultForEnumPropertyValueOfDSCResource(completionContext, string.Empty, ref replacementIndex, ref replacementLength, out unused);
}
break;
case TokenKind.AtCurly:
// Handle scenarios such as 'Sort-Object @{<tab>' and 'gci | Format-Table @{'
result = GetResultForHashtable(completionContext);
replacementIndex += 2;
replacementLength = 0;
break;

case TokenKind.Number:
// Handle scenarios such as Get-Process -Id 5<tab> || Get-Process -Id 5210, 3<tab> || Get-Process -Id: 5210, 3<tab>
Expand Down
9 changes: 9 additions & 0 deletions test/powershell/Host/TabCompletion/BugFix.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,13 @@ Describe "Tab completion bug fix" -Tags "CI" {
$result.CompletionMatches[1].CompletionText | Should Be $DatetimeProperties[1].Name # DateTime
}
}

It "Issue#3628 - 'Sort-Object @{<tab>' should work" {
$cmd = "Get-Date | Sort-Object @{"
$result = TabExpansion2 -inputScript $cmd -cursorColumn $cmd.Length
$result.CompletionMatches.Count | Should Be 3
$result.CompletionMatches[0].CompletionText | Should Be 'Expression'
$result.CompletionMatches[1].CompletionText | Should Be 'Ascending'
$result.CompletionMatches[2].CompletionText | Should Be 'Descending'
}
}