Skip to content

Commit

Permalink
Remove the regex match in strings.
Browse files Browse the repository at this point in the history
This commit just comments out the contexts for regex match in strings.
A lot of people seem to use `/` in strings that wasn't signalling the
start of a regex match causing the highlighting to go haywire.

This will be something that will be improved in the future.

Partially resolves #12.
  • Loading branch information
UltraInstinct05 committed Oct 29, 2021
1 parent 5d95adb commit e0bec1c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 35 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [1.0.5] - 2021-05-24
### Removed
- Keybindings to come out of empty statements/expression blocks.
- Keybindings to come out of empty statements/expression blocks.

## [1.0.6] - 2021-10-29
### Removed
- Regex highlighting in strings.
38 changes: 19 additions & 19 deletions resources/syntax/Twig.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -361,25 +361,25 @@ contexts:
- include: double_string_regex_match
- include: double_quoted_string

single_string_regex_match:
- match: (')(?:/)
captures:
1: punctuation.definition.string.begin.twig
embed: scope:source.regexp
embed_scope: string.quoted.single.twig
escape: (?:/{{regex_modifiers}})(')
escape_captures:
1: punctuation.definition.string.end.twig

double_string_regex_match:
- match: (")(?:/)
captures:
1: punctuation.definition.string.begin.twig
embed: scope:source.regexp
embed_scope: string.quoted.double.twig
escape: (?:/{{regex_modifiers}})(")
escape_captures:
1: punctuation.definition.string.end.twig
# single_string_regex_match:
# - match: (')(?:/)
# captures:
# 1: punctuation.definition.string.begin.twig
# embed: scope:source.regexp
# embed_scope: string.quoted.single.twig
# escape: (?:/{{regex_modifiers}})(')
# escape_captures:
# 1: punctuation.definition.string.end.twig

# double_string_regex_match:
# - match: (")(?:/)
# captures:
# 1: punctuation.definition.string.begin.twig
# embed: scope:source.regexp
# embed_scope: string.quoted.double.twig
# escape: (?:/{{regex_modifiers}})(")
# escape_captures:
# 1: punctuation.definition.string.end.twig

single_quoted_string:
- match: \'
Expand Down
8 changes: 0 additions & 8 deletions resources/syntax/tests/syntax_test_expressions.twig
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,6 @@
## ^^^ variable.other.twig
## ^ punctuation.accessor.dot.twig

{{ '/^[\\d\\.]+$/' "/^[\\d\\.]+$/" }}
## ^^^^^^^^^^^ source.regexp
## ^^^^^^^^^^^ source.regexp

{{ '/^[\\d\\.]+$/iu' "/^[\\d\\.]+$/iu" }}
## ^^^^^^^^^^^ source.regexp
## ^^^^^^^^^^^ source.regexp

{{ foo ? 'yes' : 'no' }}
## ^^^^^^^^^^^^^^^^^^^^^^^^ meta.placeholder.twig
## ^^ punctuation.definition.placeholder.begin.twig
Expand Down
7 changes: 0 additions & 7 deletions resources/syntax/tests/syntax_test_statements.twig
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,6 @@
## ^ keyword.operator.assignment.twig
## ^ punctuation.separator.parameters.twig

{% '/^[\\d\\.]+$/' "/^[\\d\\.]+$/" %}
## ^^^^^^^^^^^ source.regexp
## ^^^^^^^^^^^ source.regexp

{% '/^[\\d\\.]+$/iu' "/^[\\d\\.]+$/iu" %}
## ^^^^^^^^^^^ source.regexp
## ^^^^^^^^^^^ source.regexp

{% [1 + 2 - 3 * 4 / 5 // 6 % 7 ** 9] %}
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.statement.twig
Expand Down

0 comments on commit e0bec1c

Please sign in to comment.