PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.69k stars 481 forks source link

IntelliSense is not triggered by trigger characters #5022

Open MartinGC94 opened 1 month ago

MartinGC94 commented 1 month ago

Prerequisites

Summary

VS code will by default trigger IntelliSense when you start typing, however you can turn this off and only have it get triggered when certain characters are typed. This is controlled by the following settings:

"editor.suggestOnTriggerCharacters": true,
    "editor.quickSuggestions": {
        "other": "off",
        "comments": "off",
        "strings": "off"
    }

If you set these settings and try to edit the VS code settings.json file you will see that IntelliSense is automatically triggered when you type in " but not when you type normal words, so it works exactly as you'd expect. In PowerShell the only trigger characters that work are . and \ but there are more triggers defined in editor services: https://github.com/PowerShell/PowerShellEditorServices/blob/main/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs#L56

This setting used to work just fine back in 2021 when I added $ as a trigger character: https://github.com/PowerShell/PowerShellEditorServices/pull/1427 but I have no idea when it stopped working.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.5.0-preview.3
PSEdition                      Core
GitCommitId                    7.5.0-preview.3
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Name             : Visual Studio Code Host
Version          : 2024.3.2
InstanceId       : 7aca87d3-2cd2-4ec6-984c-9d163813f6d5
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : da-DK
CurrentUICulture : da-DK
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

1.92.0-insider
b1c0a14de1414fcdaa400695b4db1c0799bc3124
x64

Extension Version

ms-vscode.powershell@2024.3.2

Steps to Reproduce

Configure the following VS code settings:

"editor.suggestOnTriggerCharacters": true,
    "editor.quickSuggestions": {
        "other": "off",
        "comments": "off",
        "strings": "off"
    }

Type in $ or Get- or $global: and notice how none of them trigger IntelliSense. Type in "". or C:\ and notice that IntelliSense is triggered as expected.

Visuals

No response

Logs

No response

SydneyhSmith commented 2 weeks ago

Thanks! @MartinGC94 are you saying that . and \ work but the other characters aren't working anymore?

MartinGC94 commented 2 weeks ago

Yes exactly.