Skip to content

Snippets + Auto-closing pairs don't compliment each other #104952

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
TylerLeonhardt opened this issue Aug 18, 2020 · 8 comments · Fixed by #114235
Closed

Snippets + Auto-closing pairs don't compliment each other #104952

TylerLeonhardt opened this issue Aug 18, 2020 · 8 comments · Fixed by #114235
Assignees
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders snippets verified Verification succeeded
Milestone

Comments

@TylerLeonhardt
Copy link
Member

Version: 1.49.0-insider
Commit: 11dc5a8
Date: 2020-08-17T17:11:16.078Z (1 day ago)
Electron: 9.2.0
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Darwin x64 19.6.0

Steps to Reproduce:

Add the following python snippet:

"listcompPy": {
		"prefix":"[x for x in",
		"body":[
			"[x for x in range(1,20) if x%2==0 ]"
		]
	}

or PowerShell snippet:

"PSCustomObject": {
        "prefix":"[PSCustomObject",
        "body":[
            "[PSCustomObject] @{ Key = Value }"
        ]
    }
  1. type: [ which will cause auto-closing pair... (at this point you have [|] where | is the cursor)
  2. then add a x or psc and hit TAB or ENTER on the intellisense item

Expected

Python

[x for x in range(1,20) if x%2==0 ]

PowerShell

[PSCustomObject]@{
    Name = Value
}

Actual

Python

[x for x in range(1,20) if x%2==0 ]]

PowerShell

[PSCustomObject]@{
    Name = Value
}]

NOTE THE TRAILING ]. Snippets and auto-closing pairs should play nice together so that the whole experience generates valid code.

Does this issue occur when all extensions are disabled?: Yes

@jrieken jrieken added this to the Backlog Candidates milestone Aug 19, 2020
@jrieken jrieken added the feature-request Request for new features or functionality label Aug 19, 2020
@TylerLeonhardt
Copy link
Member Author

Here's a javascript example for array destructuring:

"arraydestructuring": {
        "prefix": "[a",
        "body": [
            "[a, b, ...next] = ${1:array}"
        ],
        "description": "arraydestructuring"
    }

which gets you:

[a, b, ...next] = array]

when you type: [a<TAB or ENTER to accept intellisense>

@TylerLeonhardt
Copy link
Member Author

better example!

A javascript example for Symbol.iterator:

"SymbolIterator": {
		"prefix": "[Symbol.iterator",
		"body": [
			"[Symbol.iterator]: () => {",
			"    return {",
			"        next: () => {",
			"            return { value: value, done: false };",
			"        }",
			"    };",
			"}"
		]
	}

which gets you:

[Symbol.iterator]: () => {
        return {
            next: () => {
                return { value: value, done: false };
            }
        };
    }]

Notice the extra ] at the end

when you type: [Symbol<TAB or ENTER to accept intellisense>

@TylerLeonhardt
Copy link
Member Author

for verification, this:

"PSCustomObject": {
        "prefix":"[PSCustomObject]",
        "body":[
            "[PSCustomObject] @{ Key = Value }"
        ]
    }

should get you:

[PSCusomObject] @{ Key = Value }

on insert mode replace (default is SHIFT + ENTER)

@aeschli aeschli added verified Verification succeeded and removed verification-needed Verification of issue is requested labels Jan 26, 2021
@ArturoDent
Copy link

I'll note that it works fine in non-json files, but is reversed in a json file (as are the insert/replace hints in the suggestion box).

W10

@TylerLeonhardt
Copy link
Member Author

that seems like a separate issue not related to this fix. Can you open a new issue?

@ArturoDent
Copy link

Yes, I'll open another issue.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders snippets verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants
@jrieken @TylerLeonhardt @aeschli @ArturoDent and others