Skip to content

Commit 8628ded

Browse files
committed
Fix toggle comment
Apply comment scope to interpolation punctuation, so ST's toggle_comment can do its job better with `{/* */}`.
1 parent 5d37104 commit 8628ded

3 files changed

Lines changed: 39 additions & 7 deletions

File tree

Embeddings/HTML (for MDX).sublime-syntax

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,50 @@ contexts:
113113
- meta_include_prototype: false
114114
- meta_scope: meta.interpolation.markdown
115115
- meta_content_scope: source.jsx.embedded.markdown
116-
- include: jsx-interpolation-body
116+
- include: jsx-interpolation-plain-body
117117

118118
jsx-interpolations:
119+
- match: (?={/\*)
120+
branch_point: jsx-interpolation-comment
121+
branch:
122+
- jsx-interpolation-comment
123+
- jsx-interpolation-plain
124+
- match: (?={)
125+
push: jsx-interpolation-plain
126+
127+
jsx-interpolation-comment:
128+
- meta_include_prototype: false
129+
- match: ({)(/\*)
130+
captures:
131+
1: punctuation.section.interpolation.begin.markdown
132+
2: punctuation.definition.comment.begin.js
133+
set: jsx-interpolation-comment-body
134+
135+
jsx-interpolation-comment-body:
136+
- meta_include_prototype: false
137+
- meta_scope: meta.interpolation.markdown comment.block.js
138+
- match: (\*/)(})
139+
captures:
140+
1: punctuation.definition.comment.end.js
141+
2: punctuation.section.interpolation.end.markdown
142+
pop: 1
143+
- match: (?=\*/)
144+
fail: jsx-interpolation-comment
145+
146+
jsx-interpolation-plain:
147+
- meta_include_prototype: false
119148
- match: \{
120149
scope: punctuation.section.interpolation.begin.markdown
121-
push: jsx-interpolation-body
150+
set: jsx-interpolation-plain-body
122151

123-
jsx-interpolation-body:
152+
jsx-interpolation-plain-body:
124153
- meta_include_prototype: false
125154
- meta_scope: meta.interpolation.markdown
126155
- meta_content_scope: source.jsx.embedded.markdown
127156
- match: \}
128157
scope: punctuation.section.interpolation.end.markdown
129158
pop: 1
130-
- include: scope:source.jsx#script
131-
apply_prototype: true
159+
- match: (?=\S)
160+
push:
161+
- scope:source.jsx#expression-end
162+
- scope:source.jsx#expression-begin

MDX.sublime-syntax

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ variables:
7272
contexts:
7373

7474
prototype:
75+
- meta_prepend: true
7576
- include: scope:text.html.embedded.mdx#jsx-interpolations
7677

7778
markdown:

tests/syntax_test_mdx.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,13 @@ This is a single
179179
| ^^^^^ entity.other.attribute-name.style.html
180180
| ^ punctuation.separator.key-value.html
181181
| ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html
182-
| ^^^^^^^^^^ meta.string.html meta.interpolation.html source.css.embedded.html
182+
| ^^^^^^^^^^ meta.string.html source.css.embedded.html
183183
| ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html
184184
| ^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.event.html
185185
| ^^^^^^^ entity.other.attribute-name.event.html
186186
| ^ punctuation.separator.key-value.html
187187
| ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html
188-
| ^^^^^^^^^^ meta.string.html meta.interpolation.html source.js.embedded.html meta.function-call
188+
| ^^^^^^^^^^ meta.string.html source.js.embedded.html meta.function-call
189189
| ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html
190190
| ^ punctuation.definition.tag.end.html
191191

0 commit comments

Comments
 (0)