From 6f4db616d1b6069ee2c85f0ccf7e41fbd52cb5e0 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Wed, 7 Aug 2024 05:32:08 -0700 Subject: [PATCH] Add all pwsh keywords as completions Fixes #225042 --- .../browser/media/shellIntegration.ps1 | 115 +++++++++++++++++- 1 file changed, 113 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.ps1 b/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.ps1 index 58438e4f12f..d6a560ba6f6 100644 --- a/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.ps1 +++ b/src/vs/workbench/contrib/terminal/browser/media/shellIntegration.ps1 @@ -170,6 +170,13 @@ function Set-MappedKeyHandler { } } +function Get-KeywordCompletionResult( + $Keyword, + $Description = $null +) { + [System.Management.Automation.CompletionResult]::new($Keyword, $Keyword, [System.Management.Automation.CompletionResultType]::Keyword, $null -ne $Description ? $Description : $Keyword) +} + function Set-MappedKeyHandlers { Set-MappedKeyHandler -Chord Ctrl+Spacebar -Sequence 'F12,a' Set-MappedKeyHandler -Chord Alt+Spacebar -Sequence 'F12,b' @@ -191,8 +198,112 @@ function Set-MappedKeyHandlers { # Get commands, convert to string array to reduce the payload size and send as JSON $commands = @( [System.Management.Automation.CompletionCompleters]::CompleteCommand('') - # Keywords aren't included in CompletionCommand - [System.Management.Automation.CompletionResult]::new('exit', 'exit', [System.Management.Automation.CompletionResultType]::Keyword, "exit []") + Get-KeywordCompletionResult -Keyword 'begin' + Get-KeywordCompletionResult -Keyword 'break' + Get-KeywordCompletionResult -Keyword 'catch' -Description "catch [[][',' ]*] {}" + Get-KeywordCompletionResult -Keyword 'class' -Description @" +class [: [][,]] { + [[] [hidden] [static] ...] + [([]) + {} ...] + [[] [hidden] [static] ...] +} +"@ + Get-KeywordCompletionResult -Keyword 'clean' + Get-KeywordCompletionResult -Keyword 'continue' + Get-KeywordCompletionResult -Keyword 'data' -Description @" +data [] [-supportedCommand ] { + +} +"@ + Get-KeywordCompletionResult -Keyword 'do' -Description @" +do {} while () +do {} until () +"@ + Get-KeywordCompletionResult -Keyword 'dynamicparam' -Description "dynamicparam {}" + Get-KeywordCompletionResult -Keyword 'else' -Description @" +if () + {} +[elseif () + {}] +[else + {}] +"@ + Get-KeywordCompletionResult -Keyword 'elseif' -Description @" +if () + {} +[elseif () + {}] +[else + {}] +"@ + Get-KeywordCompletionResult -Keyword 'end' + Get-KeywordCompletionResult -Keyword 'enum' -Description @" +[[]...] [Flag()] enum [ : ] { +