Prevent fallback to file completion when tab completing type names (#20084)

This commit is contained in:
MartinGC94
2023-08-21 10:56:55 -07:00
committed by GitHub
parent 39513bb3fb
commit 050873fc28
2 changed files with 7 additions and 1 deletions
@@ -1128,7 +1128,7 @@ namespace System.Management.Automation
replacementIndex = typeNameToComplete.Extent.StartOffset;
replacementLength = typeNameToComplete.Extent.EndOffset - replacementIndex;
completionContext.WordToComplete = typeNameToComplete.FullName;
result = CompletionCompleters.CompleteType(completionContext);
return CompletionCompleters.CompleteType(completionContext);
}
}
@@ -2626,6 +2626,12 @@ function MyFunction ($param1, $param2)
$res = TabExpansion2 -inputScript 'using module @{'
$res.CompletionMatches.CompletionText -join ' ' | Should -BeExactly "GUID MaximumVersion ModuleName ModuleVersion RequiredVersion"
}
It 'Should not fallback to file completion when completing typenames' {
$Text = '[abcdefghijklmnopqrstuvwxyz]'
$res = TabExpansion2 -inputScript $Text -cursorColumn ($Text.Length - 1)
$res.CompletionMatches | Should -HaveCount 0
}
}
Describe "Tab completion tests with remote Runspace" -Tags Feature,RequireAdminOnWindows {