Skip to content

Commit

Permalink
[JavaScript] Refactor unmatched closing tags
Browse files Browse the repository at this point in the history
This commit reduces amount of contexts pushed on stack
to handle unmatched tags. As new merged context shares patterns with
`jsx-expect-tag-end` compiled syntax cache doesn't change.
  • Loading branch information
deathaxe committed Dec 15, 2024
1 parent fb126eb commit 148cac3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 7 additions & 7 deletions JavaScript/JSX.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,19 @@ contexts:
- match: /
scope: punctuation.definition.tag.begin.js
set:
- jsx-meta-unmatched-tag
- jsx-expect-tag-end
- jsx-expect-unmatched-tag-end
- jsx-tag-name
- match: (?=\S)
set:
- jsx-tag-attributes
- jsx-tag-name

jsx-expect-unmatched-tag-end:
- meta_include_prototype: false
- meta_scope: invalid.illegal.unmatched-tag.js
- meta_content_scope: meta.tag.js
- include: jsx-expect-tag-end

jsx-child-tag:
- match: <(?=\s*[/>{{jsx_tag_name_start}}])
scope: punctuation.definition.tag.begin.js
Expand Down Expand Up @@ -118,11 +123,6 @@ contexts:
pop: 1
- include: else-pop

jsx-meta-unmatched-tag:
- meta_include_prototype: false
- meta_scope: invalid.illegal.unmatched-tag.js
- include: immediately-pop

jsx-tag-attributes:
- meta_content_scope: meta.tag.attributes.js
- match: '>{2,}' # ignore invalid punctuation
Expand Down
3 changes: 1 addition & 2 deletions JavaScript/TSX.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ contexts:
- match: /
scope: punctuation.definition.tag.begin.js
set:
- jsx-meta-unmatched-tag
- jsx-expect-tag-end
- jsx-expect-unmatched-tag-end
- jsx-tag-name
- match: (?=\S)
set:
Expand Down

0 comments on commit 148cac3

Please sign in to comment.