@@ -150,6 +150,46 @@ Describe "TabCompletion" -Tags CI {
150
150
$res.CompletionMatches [0 ].ToolTip | Should - BeExactly $Expected
151
151
}
152
152
153
+ It ' Should complete environment variable' {
154
+ try {
155
+ $env: PWSH_TEST_1 = ' value 1'
156
+ $env: PWSH_TEST_2 = ' value 2'
157
+
158
+ $res = TabExpansion2 - inputScript ' $env:PWSH_TEST_'
159
+ $res.CompletionMatches.Count | Should - Be 2
160
+ $res.CompletionMatches [0 ].CompletionText | Should - BeExactly ' $env:PWSH_TEST_1'
161
+ $res.CompletionMatches [0 ].ListItemText | Should - BeExactly ' PWSH_TEST_1'
162
+ $res.CompletionMatches [0 ].ToolTip | Should - BeExactly ' PWSH_TEST_1'
163
+ $res.CompletionMatches [1 ].CompletionText | Should - BeExactly ' $env:PWSH_TEST_2'
164
+ $res.CompletionMatches [1 ].ListItemText | Should - BeExactly ' PWSH_TEST_2'
165
+ $res.CompletionMatches [1 ].ToolTip | Should - BeExactly ' PWSH_TEST_2'
166
+ }
167
+ finally {
168
+ $env: PWSH_TEST_1 = $null
169
+ $env: PWSH_TEST_2 = $null
170
+ }
171
+ }
172
+
173
+ It ' Should complete function variable' {
174
+ try {
175
+ Function Test-PwshTest1 {}
176
+ Function Test-PwshTest2 {}
177
+
178
+ $res = TabExpansion2 - inputScript ' ${function:Test-PwshTest'
179
+ $res.CompletionMatches.Count | Should - Be 2
180
+ $res.CompletionMatches [0 ].CompletionText | Should - BeExactly ' ${function:Test-PwshTest1}'
181
+ $res.CompletionMatches [0 ].ListItemText | Should - BeExactly ' Test-PwshTest1'
182
+ $res.CompletionMatches [0 ].ToolTip | Should - BeExactly ' Test-PwshTest1'
183
+ $res.CompletionMatches [1 ].CompletionText | Should - BeExactly ' ${function:Test-PwshTest2}'
184
+ $res.CompletionMatches [1 ].ListItemText | Should - BeExactly ' Test-PwshTest2'
185
+ $res.CompletionMatches [1 ].ToolTip | Should - BeExactly ' Test-PwshTest2'
186
+ }
187
+ finally {
188
+ Remove-Item function:Test-PwshTest1 - ErrorAction SilentlyContinue
189
+ Remove-Item function:Test-PwshTest1 - ErrorAction SilentlyContinue
190
+ }
191
+ }
192
+
153
193
It ' Should complete scoped variable with description and value <Value>' - TestCases @ (
154
194
@ { Value = 1 ; Expected = ' [int]$VariableWithDescription - Variable description' }
155
195
@ { Value = ' string' ; Expected = ' [string]$VariableWithDescription - Variable description' }
0 commit comments