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

scope name capture substitution seem to trigger only once #147

Closed
msftrncs opened this issue Feb 26, 2021 · 1 comment · Fixed by #148
Closed

scope name capture substitution seem to trigger only once #147

msftrncs opened this issue Feb 26, 2021 · 1 comment · Fixed by #148
Milestone

Comments

@msftrncs
Copy link
Contributor

With a scope reference such as:

	"name": "storage.type.$0.powershell keyword.declaration.$0.powershell"

The $0 replacement only seems to happen on the first instance, as I get the following result:
image

My understanding is that these are equivalent to regex replacements (only nothing is getting replaced), and of all the regex engines I have used the 'replace' function on seem to handle multiple references to the same capture.

However, I cannot confirm any other TextMate based editor works differently, though I will be able to try Atom at some point.

@msftrncs msftrncs changed the title scope name capture replacements seem to trigger only once scope name capture substitution seem to trigger only once Feb 27, 2021
@msftrncs
Copy link
Contributor Author

I can confirm that this seems to work as expected in Atom (1.41 and 1.54).

image

(However note that Atom considers the entire string as a single scope, instead of two, and this causes some issues with how themes apply)

I think I have tracked this down to a lack of a global modifier on the regex that handles this. Tracking this down caused me to learn that there is a method for 'casing' the substitution, good to know!

${n:/upcase}
${n:/downcase}

Where n refers to the capture group contents to be substituted.

msftrncs added a commit to msftrncs/vscode-textmate that referenced this issue Feb 27, 2021
Add the global modifier to the regex that handles scope name capture
substitutions for instances where more than one substitution exists.

Fixes microsoft#147
msftrncs added a commit to msftrncs/vscode-textmate that referenced this issue Feb 27, 2021
Add the global modifier to the regex that handles scope name capture
substitutions for instances where more than one substitution exists.

Fixes microsoft#147
msftrncs added a commit to msftrncs/vscode-textmate that referenced this issue Feb 27, 2021
Implements a test for issue microsoft#147, to insure that multiple substitutions
on a single scope specification are handled.
@alexdima alexdima added this to the March 2021 milestone Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants