Skip to content

Tabbing [PSCustomObject] adds an additional ']' #3349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SwarfegaGit opened this issue May 14, 2021 · 2 comments
Closed

Tabbing [PSCustomObject] adds an additional ']' #3349

SwarfegaGit opened this issue May 14, 2021 · 2 comments
Labels
Area-Snippets Issue-Bug A bug to squash. Resolution-External Will close automatically. Up for Grabs Will shepherd PRs.

Comments

@SwarfegaGit
Copy link

System Details

### VSCode version: 1.56.0 cfa2e218100323074ac1948c885448fdf4de2a7f x64

### VSCode extensions:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]


### PSES version: 2.3.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      7.1.3
PSEdition                      Core
GitCommitId                    7.1.3
OS                             Microsoft Windows 10.0.19041
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
System Details Output

Issue Description

AutoCompleting with tab when typing [PSCustomObject] adds an additional square bracket at the end.

In a blank file if you type a '[' the editor will automatically add a ]. Then type ps which it will recommend [PSCustomObject] so press tab to accept this. The autocomplete works but there's an additional ']'. See the actual behaviour section below.

Expected Behaviour

[PSCustomObject]@{
    Name = Value
}

Actual Behaviour

[PSCustomObject]@{
    Name = Value
}]
@ghost ghost added the Needs: Triage Maintainer attention needed! label May 14, 2021
@SydneyhSmith SydneyhSmith added Area-Snippets Issue-Bug A bug to squash. Up for Grabs Will shepherd PRs. and removed Needs: Triage Maintainer attention needed! labels May 18, 2021
@wsmelton
Copy link

I would mention this is a VS Code issue more than extension. @TylerLeonhardt fixed this issue at one point in VS Code in microsoft/vscode#114235. An additional change was made in the extension for preview 2020.5.0 #3129 to address it, but I think this is still on Code's side if it is to be fixed.

The proper use of snippets is not to include the brackets first. Type the alias and then tab key will create a proper object based on the snippet. I create snippets based on projects and use the snippet-generator.app site to take scripts or code blocks and convert them more easily.

vscode_snippet_usage

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label May 23, 2021
@TylerLeonhardt
Copy link
Member

So there are actually 2 different behaviors of accepting a completion.

You can see what options are available if you have the setting editor.suggest.showStatusBar on.

One will be mapped to Enter, one will be Shift+Enter.

The default behavior of Enter is controlled via the setting editor.suggest.insertMode.

  • insert (default): doesn't replace any trailing characters. It only inserts them.
  • replace: will replace characters after the cursor if the snippet can

Note: Tab I believe has the same behavior of Enter so if you see Enter above it should also apply to Tab I think.

So I think if you use Shift+Enter or set the insertMode to replace this should work.

@SydneyhSmith SydneyhSmith added Resolution-External Will close automatically. and removed Needs: Maintainer Attention Maintainer attention needed! labels May 27, 2021
@ghost ghost closed this as completed May 27, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Snippets Issue-Bug A bug to squash. Resolution-External Will close automatically. Up for Grabs Will shepherd PRs.
Projects
None yet
Development

No branches or pull requests

4 participants