Skip to content
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

Snippet optional transforms are not applied correctly when reusing the same variable #37702

Closed
dogoku opened this issue Nov 6, 2017 · 0 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug snippets verified Verification succeeded
Milestone

Comments

@dogoku
Copy link

dogoku commented Nov 6, 2017

  • VSCode Version: Insiders v1.18.0 (86e057c)
  • OS Version: N/A

Related to #36089, transforms are working for optional matches, however, when reusing the same variable (e.g. $1) only the first transform is applied.

Given the following simplified example:

//TM_FILENAME_BASE: `my-awesome-module`
[
"function ${1:${TM_FILENAME_BASE/^(.)|-(.)/${1:/upcase}${2:/upcase}/g}} () {}",
"module.exports = $1;" //<<<< BROKEN
]

//Expected
function MyAwesomeModule () {}
module.exports = MyAwesomeModule;

//Actual
function MyAwesomeModule () {}
module.exports = My-awesome-module;

In case you missed it, the second use of $1 was not transformed properly, having only the first transform applied to it ${1:/upcase}, where as the second transform ${2:/upcase} was not applied at all, resulting in the string My-awesome-module instead of MyAwesomeModule

This is not the case for normal transforms (non-optional), e.g:

//TM_FILENAME_BASE: `myfile`
[
//Upcase the first 2 letters
"function ${1:${TM_FILENAME_BASE/^(.)(.)/${1:/upcase}${2:/upcase}/g}} () {}",
"module.exports = $1;"
]

//Result:
function MYfile () {}
module.exports = MYfile;
@vscodebot vscodebot bot added the insiders label Nov 6, 2017
@vscodebot vscodebot bot assigned mjbvz Nov 6, 2017
@vscodebot vscodebot bot added the javascript JavaScript support issues label Nov 6, 2017
@jrieken jrieken assigned jrieken and unassigned mjbvz Nov 6, 2017
@jrieken jrieken added snippets bug Issue identified by VS Code Team member as probable bug and removed insiders javascript JavaScript support issues labels Nov 6, 2017
@jrieken jrieken added this to the November 2017 milestone Nov 8, 2017
@jrieken jrieken closed this as completed in 94e9b10 Nov 8, 2017
@roblourens roblourens added the verified Verification succeeded label Dec 6, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug snippets verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants