question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Snippet transformation does not work with nested snippets

See original GitHub issue

VS Code version: Code 1.51.1 (e5a624b788d92b8d34d1392e4c4d9789406efe8f, 2020-11-10T23:34:32.027Z) OS version: Windows_NT x64 10.0.18363

I’ve written a snippet that transforms TypeScript interfaces to JSON key-values where the key is the name of the TS property and the value is the name of the type.

Example:

// input:
{
    myFirstProp: string;
    mySecondProp: number;
}
// output:
{
    myFirstProp: 'string',
    mySecondProp: 'number',
}

This is the snippet source:

"body": [
	"$1",
	"\n${1/([A-Za-z0-9]+): ([A-Za-z]+).*/$1: '$2',/gm}"
]

When the snippet is active and I’m typing the TS interface, I get the suggestion/autocomplete while typing. If I hit ESC before typing the semicolon that ends each line, then the snippet works great. But if I don’t hit ESC, the snippet stops executing.

Steps to Reproduce:

I’ve recorded two gifs using a keylogger that lets you see which keys I’m hitting. Note that I’m on a Swedish keyboard, which the keylogger doesn’t seem to support, so when I type : it will display it as > and when I type ; it will display <.

Here’s when I’m hitting escape before the semicolon:

with_escape

Here’s when I don’t hit escaoe before the semicolon, which makes the snippet stop executing:

without_escape

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jriekencommented, Mar 2, 2021

Note that I’m on a Swedish keyboard, which the keylogger doesn’t seem to support, so when I type : it will display it as > and when I type ; it will display <.

fyi - we have “F1 > Toggle Screencast Mode” which might be more true wrt what you are typing

1reaction
jriekencommented, Mar 2, 2021

Yeah, this is a bug that snippet transformations don’t work on nested snippet invocation (which completions are)

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode nested snippets (or include a snippet inside another ...
I think the only way to include or nest snippets within each other is to use a macro or some other programmatic ...
Read more >
Snippets in Visual Studio Code
Snippets in Visual Studio Code. Code snippets are templates that make it easier to enter repeating code patterns, such as loops or conditional-statements....
Read more >
Writing snippets
Quickly finding snippets; Using the snippet-mode major mode ... If you don't specify this, the snippet will not be expandable through the trigger...
Read more >
Snippets - Sublime Text Unofficial Documentation
The content of your snippet must not contain ]]> because this string of characters will prematurely close the <![CDATA[…]]> section, resulting in an...
Read more >
Sisense SQL snippets - GitLab
The snippet also goes to great lengths to find out when a merge request was last active. Given that the state could either...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found