PowerShell / vscode-powershell

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

In VSCode tab-completion doesn't fix the casing as it does in PowerShell ISE #1624

Open alexandair opened 5 years ago

alexandair commented 5 years ago

There is one thing that I used to use a lot in ISE, and is missing in PowerShell extension. In ISE, if I type "get-date" (all lower case) and then later position a cursor inside of it and press "TAB", it tab-completes to a proper casing. In VSCode, the "TAB" in that case add a tab. Could you bring back the ISE behavior?

dsolodow commented 5 years ago

It's a configurable setting in VSCode; just off by default. "Editor: Tab Completion" needs to be set to On under Preferences

{
    "editor.tabCompletion": "on"
}
alexandair commented 5 years ago

@dsolodow That settings doesn't work for me. If you type "get-date" and a space, and then return and put cursor in "get-date", after you press "TAB" does it change it to "Get-Date"?

rjmholt commented 5 years ago

@alexandair If you trigger a completion in another way, does get-date have its casing changed? If so, then the remaining work lies with VSCode's completion experience. The enhancement in that case would lie within VSCode, since we don't have any way to change that experience.

alexandair commented 5 years ago

@rjmholt What would be another way?

Here is one more example when tab-completion is lacking in VSCode editor: In Windows PowerShell console, PowerShell ISE, PowerShell Core console, and Integrated PowerShell Console, the following works, but not in the VSCode editor:

TAB after Get-Service -Name gives you a list of services.

SeeminglyScience commented 5 years ago

@alexandair CTRL + SPACE forces a completion request. I think VSCode would need to add an option that makes TAB only indent if all the characters to the left of the cursor are whitespace. That would give a similar experience.

alexandair commented 5 years ago

@SeeminglyScience For me, tab-completion involves pressing the TAB key. CTRL+SPACE triggers the IntelliSense and completion could be performed with the arrows and ENTER key.

Now, that you've mentioned CTRL+SPACE, here is another example where PowerShell ISE behaves better and consistently compared to VSCode.

Get-CimClass -Namespace

PowerShell ISE: In both, Script and Console pane, TAB circles through the list of namespaces and CTRL+SPACE triggers IntelliSense.

VSCode: In Editor only CTRL+SPACE works, but not TAB. In terminal only TAB works, CTRL+SPACE is ignored.

rjmholt commented 5 years ago

See also https://github.com/PowerShell/vscode-powershell/issues/25.

The completion features for the terminal will be added by https://github.com/PowerShell/vscode-powershell/issues/535.

For the remaining Tab-completion desire, you should open a new feature request with VSCode. It's worth noting that the current "tabCompletion": "on" setting is totally orthogonal to us even though many PowerShell extension users see it as an ISE parity feature -- it just configures VSCode and we are completely agnostic as to its setting.

alexandair commented 5 years ago

@rjmholt I looked at #25. My latest example is after I set "tabCompletion": "on". I don't see that setting changed anything for me. If I file the original casing issue to the VSCode repo, I have a feeling they will immediately say "Oh, that's PowerShell extension issue". :)

TylerLeonhardt commented 5 years ago

@alexandair RE: "tabCompletion":"on" I noticed that when you hit TAB, it completes with the first completion... but then AFTER that you can continue to hit TAB to cycle.

I thought it would cycle through the intellisense pop-up but it has a different behavior.

rkeithhill commented 5 years ago

they will immediately say "Oh, that's PowerShell extension issue"

I dunno @alexandair. When I try this while monitoring the log file I do not see any textDocument/completion from VSCode. If they don't send us the request, I'm not sure there is much we can do about it by then other than to monkey around with document change notification we get. We already have a command that can expand all aliases in a document. How about we add a command to "properly" cases all commands and their parameters in the document/.

TylerLeonhardt commented 5 years ago

Current "tabCompletion":"on" behavior for reference. Imgur

How about we add a command to "properly" cases all commands and their parameters in the document/.

This makes the most sense. That way we don't have to re-implement completions for our specific use-cases. It still would be good to have an issue on VSCode to give more power over completions.