Skip to content

Commit 9140e42

Browse files
TylerLeonhardtTravisEz13
authored andcommitted
Add wildcard back to end of tab completion command lookup (#9383)
Re-add wildcard when searching AST + Missed test case. ## PR Context In #8109, we removed the line that added a wildcard to the end of the command that was used to match commands in the script AST. This readds that line closer to where it is used.
1 parent e9ffbe5 commit 9140e42

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

‎src/System.Management.Automation/engine/CommandCompletion/CompletionCompleters.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ private static List<CompletionResult> CompleteCommand(CompletionContext context,
103103

104104
if (lastAst != null)
105105
{
106+
// We need to add the wildcard to the end so the regex is built correctly.
107+
commandName += "*";
108+
106109
// Search the asts for function definitions that we might be calling
107110
var findFunctionsVisitor = new FindFunctionsVisitor();
108111
while (lastAst.Parent != null)

‎test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,7 @@ Describe "TabCompletion" -Tags CI {
485485
@{ inputStr = '$A=[datetime]::now;$A.'; expected = 'Date'; setup = $null }
486486
@{ inputStr = 'try { 1/0 } catch {};$error[0].'; expected = 'CategoryInfo'; setup = $null }
487487
@{ inputStr = '$x= gps pwsh;$x.*pm'; expected = 'NPM'; setup = $null }
488+
@{ inputStr = 'function Get-ScrumData {}; Get-Scrum'; expected = 'Get-ScrumData'; setup = $null }
488489
@{ inputStr = 'function write-output {param($abcd) $abcd};Write-Output -a'; expected = '-abcd'; setup = $null }
489490
@{ inputStr = 'function write-output {param($abcd) $abcd};Microsoft.PowerShell.Utility\Write-Output -'; expected = '-InputObject'; setup = $null }
490491
@{ inputStr = '[math]::Co'; expected = 'Cos('; setup = $null }

0 commit comments

Comments
 (0)