vscode-powershell
vscode-powershell copied to clipboard
Variable IntelliSense completion in quotation marks
System Details
- Operating system name and version: Windows 10 1803
- VS Code version: 1.23.0
- PowerShell extension version: 1.7.0
- Output from
$PSVersionTable:
Name Value
---- -----
PSVersion 5.1.17134.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:
code -v
1.23.0
7c7da59c2333a1306c41e6e7b68d7f0caa7b3d45
x64
$pseditor.EditorServicesVersion
code --list-extensions --show-versions
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
Issue Description
When using a string with a variable in, the variable name does not auto-complete with IntelliSense like when outside the string.
For example you have the following code:
$var_test_1 = "This is a variable"
Write-Host "Test string $var_test_1"

What I would expect would be when I start typing the $var section that I would be given the created variable name.
When outside the quotes the variable name is provided. E.g.
$var_test_1 = "This is a variable"
Write-Host "var: " $var_test_1
If I just enter $v I'm provided with the full name $var_test_1

Validated that this is a legitimate bug, and doesn't occur unless you're in VS Code.
I, too, would love to see this fixed, as well, and hoping to cover the case mentioned above...
this_autocompletes="$this_does_not"
...as well as this case, in which the variable name is within both brackets and double quotes...
this_autocompletes="${this_does_not}"
...not to mention this case that I run into plenty when building strings:
this_autocompletes="But this one '${does_not}'..."
Thanks for looking at this!
I'm Powershell Preview 2020.2.0 and this is still an issue.
Oh I just realised this isn't a completion bug, it's a completion trigger issue; it you press Ctrl+Space, you get the intellisense.
We need some way of telling VSCode to trigger a completion, but I'm not sure if that's possible within strings. We'll have to look into it
Hi all, I looked into this and it's actually a VS Code setting. To enable this, you need to go to the setting editor.quickSuggestions and then for the strings item set its value to on, then it works as desired. Cheers!
Ah, that is indeed the solution. Thanks for this!