mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix tab completion regression (#17628)
This commit is contained in:
@@ -1689,7 +1689,7 @@ namespace System.Management.Automation
|
||||
{
|
||||
RemoveLastNullCompletionResult(result);
|
||||
|
||||
string wordToComplete = context.WordToComplete;
|
||||
string wordToComplete = context.WordToComplete ?? string.Empty;
|
||||
string quote = HandleDoubleAndSingleQuote(ref wordToComplete);
|
||||
|
||||
var pattern = WildcardPattern.Get(wordToComplete + "*", WildcardOptions.IgnoreCase);
|
||||
@@ -4126,7 +4126,7 @@ namespace System.Management.Automation
|
||||
return GenerateArgumentLocation(prevArg, position);
|
||||
}
|
||||
|
||||
if (token.Kind == TokenKind.Parameter
|
||||
if ((token.Kind == TokenKind.Parameter && token.Extent.StartOffset == arg.Parameter.Extent.StartOffset)
|
||||
|| (token.Extent.StartOffset > arg.Argument.Extent.StartOffset && token.Extent.EndOffset < arg.Argument.Extent.EndOffset))
|
||||
{
|
||||
// case 1: Get-Cmdlet -Param <tab> abc
|
||||
|
||||
@@ -499,6 +499,17 @@ ConstructorTestClass(int i, bool b)
|
||||
$diffs | Should -BeNullOrEmpty
|
||||
}
|
||||
|
||||
It 'Should complete argument for second parameter' {
|
||||
$res = TabExpansion2 -inputScript 'Get-ChildItem -Path $HOME -ErrorAction '
|
||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly Break
|
||||
}
|
||||
|
||||
It 'Should complete argument with validateset attribute after comma' {
|
||||
$TestString = 'function Test-ValidateSet{Param([ValidateSet("Cat","Dog")]$Param1,$Param2)};Test-ValidateSet -Param1 Dog, -Param2'
|
||||
$res = TabExpansion2 -inputScript $TestString -cursorColumn ($TestString.LastIndexOf(',') + 1)
|
||||
$res.CompletionMatches[0].CompletionText | Should -BeExactly Cat
|
||||
}
|
||||
|
||||
Context "Format cmdlet's View paramter completion" {
|
||||
BeforeAll {
|
||||
$viewDefinition = @'
|
||||
|
||||
Reference in New Issue
Block a user