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

.sublime-syntax - with_prototype doesn't support variables #1488

Closed
keith-hall opened this issue Nov 8, 2016 · 3 comments
Closed

.sublime-syntax - with_prototype doesn't support variables #1488

keith-hall opened this issue Nov 8, 2016 · 3 comments

Comments

@keith-hall
Copy link
Collaborator

keith-hall commented Nov 8, 2016

Summary

.sublime-syntax definitions - with_prototype doesn't support variables

Expected behavior

Variables would work in with_prototype constructs

Actual behavior

Variables don't work in with_prototype constructs

Steps to reproduce

  1. Create a syntax definition (example.sublime-syntax) in the User package folder with the following contents:

     %YAML 1.2
     ---
     # See http://www.sublimetext.com/docs/3/syntax.html
     scope: source.example-var_in_prototype
     variables:
       example: '\\.'
     contexts:
       main:
         # Strings begin and end with quotes, and use backslashes as an escape
         # character
         - match: '"'
           scope: punctuation.definition.string.begin.example
           push: double_quoted_string
           with_prototype:
             - match: '{{example}}'
               scope: constant.character.escape.variable-prototype.example
             #- match: '\\.'
             #  scope: constant.character.escape.non-variable-prototype.example
    
       double_quoted_string:
         - meta_scope: string.quoted.double.example
         - match: '{{example}}'
           scope: constant.character.escape.non-prototype.example
         - match: '"'
           scope: punctuation.definition.string.end.example
           pop: true
    
  2. Create a new view, set the syntax highlighting to the definition just created.

  3. Type/paste:

    "hello\a\b\c{{example}}"
    
  4. notice that "{{example}}" is scoped as constant.character.escape.variable-prototype.example, and "\a\b\c" is constant.character.escape.non-prototype.example instead of constant.character.escape.variable-prototype.example

If this is intended, the documentation at http://www.sublimetext.com/docs/3/syntax.html needs to be updated accordingly

Environment

  • Sublime Text:
    • Build 3125
@FichteFoll
Copy link
Collaborator

FichteFoll commented Dec 17, 2016

I'm tempted to push this to major considering how much time I lost because of it and how intransparent it is to figure out, although not many people are going to encounter it ...

@petereichinger
Copy link

Just came here to say that I encountered the same problem. Even if this is intended, at least a small sentence in the documentation would be nice.

@wbond
Copy link
Member

wbond commented Jul 10, 2020

This was fixed in build 4075

@wbond wbond closed this as completed Jul 10, 2020
jfcherng added a commit to jfcherng-sublime/ST-Official-Packages that referenced this issue Jul 10, 2020
As of ST 4075, we can use variable in with_prototype.

sublimehq/sublime_text#1488 (comment)

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
jfcherng added a commit to jfcherng-sublime/ST-Official-Packages that referenced this issue Jul 17, 2020
As of ST 4075, we can use variable in with_prototype.

sublimehq/sublime_text#1488 (comment)

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
wbond pushed a commit to sublimehq/Packages that referenced this issue Jul 20, 2020
* [PHP] Add highlight for multiline regex string

Example:

    $regex = '/
        a{0,6}
    //   ^^^^^ keyword.operator.quantifier.regexp
    /ux';

* [PHP] Add variable: regex_modifier

As of ST 4075, we can use variable in with_prototype.

sublimehq/sublime_text#1488 (comment)

* [PHP] Support comment highlighting in multiline regexes

This is not accurate since that we don't check the "x" modifier is used
but I think people won't write regexes in multiline if not using "x" modifier.
The leading "\s" before "#" is a compromise as well.

Even though, I think this is still good to have.
@wbond wbond removed their assignment Aug 7, 2020
mitranim pushed a commit to mitranim/Packages that referenced this issue Mar 25, 2022
* [PHP] Add highlight for multiline regex string

Example:

    $regex = '/
        a{0,6}
    //   ^^^^^ keyword.operator.quantifier.regexp
    /ux';

* [PHP] Add variable: regex_modifier

As of ST 4075, we can use variable in with_prototype.

sublimehq/sublime_text#1488 (comment)

* [PHP] Support comment highlighting in multiline regexes

This is not accurate since that we don't check the "x" modifier is used
but I think people won't write regexes in multiline if not using "x" modifier.
The leading "\s" before "#" is a compromise as well.

Even though, I think this is still good to have.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants