Skip to content

Prevent fallback to file completion for typenames #20084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2023
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 @@ -1128,7 +1128,7 @@ internal List<CompletionResult> GetResultHelper(CompletionContext completionCont
replacementIndex = typeNameToComplete.Extent.StartOffset;
replacementLength = typeNameToComplete.Extent.EndOffset - replacementIndex;
completionContext.WordToComplete = typeNameToComplete.FullName;
result = CompletionCompleters.CompleteType(completionContext);
return CompletionCompleters.CompleteType(completionContext);
}
}

Expand Down
6 changes: 6 additions & 0 deletions test/powershell/Host/TabCompletion/TabCompletion.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down