vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

no tab complete for predefined cmdlet param values

Open JustinWebDev opened this issue 3 years ago • 5 comments

Prerequisites

  • [X] I have written a descriptive issue title.
  • [X] I have searched all issues to ensure it has not already been reported.
  • [X] I have read the troubleshooting guide.
  • [X] I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • [X] I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.

Summary

no tab complete for predefined cmdlet param values Compare to the ISE or a PS prompt, where it works correctly.

The VSC peoples said this is an issue with the PS extension.

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.19041.1320
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1320
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Visual Studio Code Version

the instructional code doesn't work, so this is from VSC's About dlg:
Version: 1.63.2
Commit: 899d46d82c4c95423fb7e10e68eba52050e30ba3
Date: 2021-12-15T09:40:02.816Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19044

Extension Version

the instructional code doesn't work, so this is from the extension details page:
v2021.12.0
Last updated
12/22/2021, 15:56:27
Identifier
ms-vscode.powershell

Steps to Reproduce

  1. start a new PowerShell file
  2. type a cmdlet (e.g. 'get-item'), space, -err, tab <<-- this gives you "-ErrorAction"
  3. space
  4. tab, the predefined list of values (e.g., "Continue", "Ignore") does not appear THUS, you have to guess what the possible values are. Compare to the ISE or a PS prompt, where it works correctly.

Visuals

No response

Logs

No response

JustinWebDev avatar Jan 06 '22 00:01 JustinWebDev

thanks @JustinWebDev for your issue! Does this reproduce in both the PowerShell file editor as well in the integrated console? It would also be great to know if this reproduces for you in our preview extension? Thanks so much!

SydneyhSmith avatar Jan 11 '22 21:01 SydneyhSmith

Sydney, it works correctly in the integrated console.

JustinWebDev avatar Jan 11 '22 22:01 JustinWebDev

I know the VS code team said it was an extension issue, but IMO it's more of a VS code issue. Tab in VS code will insert whitespace unless you have the intellisense menu open. There is a tab completion option, but if you enable that it only tab completes if you are at the edge of a word, not in the middle of whitespaces.
The only thing the extension can do is to add space as an intellisense trigger character here: https://github.com/PowerShell/PowerShellEditorServices/blob/master/src/PowerShellEditorServices/Services/TextDocument/Handlers/CompletionHandler.cs#L56 this would cause the intellisense menu to pop up and let you tab complete the options, but you won't be able to tab complete without that menu open unless some changes are made on the VS code side.

Adding space as a trigger character could get annoying without some additional intelligence to only do it after parameters, preferably only parameters with a real form of tab completion (ValidateSet, Enums, Registered argument completer).

As a workaround, you as a user can get into the habit of using colons instead of whitespace to define parameter values like this: dir C:\ -ErrorAction:Stop. Colons will act both as an intellisense trigger character, and allow you to be close to a word so the tab completion works.

MartinGC94 avatar Jan 17 '22 01:01 MartinGC94

FWIW you can hit ctrl-space to get the possible values, and then if your editor.tabCompletion setting is set to on, it will behave as you expect image

JustinGrote avatar Jan 17 '22 20:01 JustinGrote

I'm going to re-flag this as a potential enhancement, as the behavior is as expected. As noted by @MartinGC94, completion would need to be enabled as a trigger for a space after a parameter, and would need to be done in an efficient detection manner so as not to tie up PSES in the search.

JustinGrote avatar Jan 17 '22 20:01 JustinGrote