Vscode-powershell: Intellisense should display options for paramaters automatically

Created on 2 Oct 2019  路  3Comments  路  Source: PowerShell/vscode-powershell

In the editor pane, I cannot see possible values to parameters automatically (see screenshot 1).

I can workaround the issue with Ctrl+Space but it is not intuitive (see screenshot 2). Furthermore, I think it should be shown automatically because I need this information to complete the command without errors.

Additionally, Windows PowerShell ISE has the desired behavior (see screenshot 3).

Screenshot 1:
image

Screenshot 2:
image

Screenshot 3:
image

Area-IntelliSense Issue-Enhancement

Most helpful comment

I'm in complete agreement with @inthemedium on this. The PowerShell ISE has the desired behavior, and I really want that behavior to happen in VS Code & Azure Data Studio as well.

All 3 comments

I'm in complete agreement with @inthemedium on this. The PowerShell ISE has the desired behavior, and I really want that behavior to happen in VS Code & Azure Data Studio as well.

I suspect we are constrained by the way VSCode itself handles the intellisense API calls. What it displays in the first screenshot is the "signature help" and comes from our response to when VSCode sends the textDocument/signatureHelp message (i.e. we don't control the interaction or the message sent).

I'll take a look into it, but it might not be possible to change in a useful way and it might not be for a while, since we're working on some other significant improvements at the moment.

(I think) the way the ISE does it is by invoking the Powershell completion whenever you enter a space after a parameter. You can see this by using Process monitor and looking at the file access patterns where you'll notice that it doesn't access files/folders if you type in spaces after commands or other tokens.

We can easily get the desired behavior by adding a space to the list of trigger characters here: https://github.com/PowerShell/PowerShellEditorServices/blob/81ba0c0b8efb7ee879f2ede511390ba73b0bc86e/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs#L59 but doing that has 2 issues:

  • The intellisense menu would constantly pop up to show file suggestions which IMO would be very annoying. The ISE should be showing this behavior after each parameter without a valid completion result, but I'm guessing they filter out file/folders unless it's manually invoked.
  • The performance would take a nose dive because intellisense would constantly get invoked, especially if you are in a slow PS drive (Network drive, SQL, SCCM, etc.) It would be worse than in the ISE because it would happen with every space character you enter, not just after a parameter.

I don't know how feasible it is to copy the ISE approach of only invoking completion if the cursor is right after a parameter (or a variable for stuff like $ErrorActionPreference=) but it does seem like the best way to implement this. Ideally Powershell itself would also have an option to avoid the file/folder fallback so VS code doesn't have to exclude those locally.

Was this page helpful?
0 / 5 - 0 ratings