Skip to content

Commit b83ec25

Browse files
deathaxeskyronic
authored andcommitted
Fix JS expression interpolation in directives
Addresses #216 (comment) This commit includes `JavaScript#expression-statement` context in attribute/directive values to highlight mappings correctly. The `pop: 1` is removed as the included context pops itself off stack.
1 parent 69e78bf commit b83ec25

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

Vue Component.sublime-syntax

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,17 +599,15 @@ contexts:
599599
vue-directive-value:
600600
- match: \"
601601
scope: meta.string.html string.quoted.double.html punctuation.definition.string.begin.html
602-
pop: 1
603-
embed: scope:source.js
602+
embed: scope:source.js#expression-statement
604603
embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html
605604
escape: \"
606605
escape_captures:
607606
0: meta.attribute-with-value.directive.html meta.string.html string.quoted.double.html
608607
punctuation.definition.string.end.html
609608
- match: \'
610609
scope: meta.string.html string.quoted.single.html punctuation.definition.string.begin.html
611-
pop: 1
612-
embed: scope:source.js
610+
embed: scope:source.js#expression-statement
613611
embed_scope: meta.string.html meta.interpolation.html source.js.embedded.html
614612
escape: \'
615613
escape_captures:

Vue Component.sublime-syntax.yaml-macros

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,7 @@ contexts:
362362
scope:
363363
meta.string.html string.quoted.double.html
364364
punctuation.definition.string.begin.html
365-
pop: 1
366-
embed: scope:source.js
365+
embed: scope:source.js#expression-statement
367366
embed_scope:
368367
meta.string.html meta.interpolation.html
369368
source.js.embedded.html
@@ -377,8 +376,7 @@ contexts:
377376
scope:
378377
meta.string.html string.quoted.single.html
379378
punctuation.definition.string.begin.html
380-
pop: 1
381-
embed: scope:source.js
379+
embed: scope:source.js#expression-statement
382380
embed_scope:
383381
meta.string.html meta.interpolation.html
384382
source.js.embedded.html

tests/syntax_tests_mustage.vue

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,31 @@
3838
// ^^^^^^^^^^^ source.js.embedded.vue
3939
// ^^ punctuation.definition.template.end.html - source.js
4040

41-
<p v-attrib="let i = 0">
41+
<p v-attrib="{'key': 'value'}">
4242
// ^^^ meta.tag - meta.attribute-with-value
4343
// ^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html - meta.string
4444
// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation
45-
// ^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html meta.string.html meta.interpolation.html source.js.embedded.html
46-
// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation
47-
// ^ meta.tag - meta.attribute-with-value
48-
// ^ - meta.tag
45+
// ^^^^^^^^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html meta.string.html meta.interpolation.html source.js.embedded.html meta.mapping
46+
// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation
47+
// ^ meta.tag - meta.attribute-with-value
48+
// ^ - meta.tag
4949

50-
<p v-attrib='let i = 0'>
50+
<p v-attrib="i = 0">
5151
// ^^^ meta.tag - meta.attribute-with-value
5252
// ^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html - meta.string
5353
// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation
54-
// ^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html meta.string.html meta.interpolation.html source.js.embedded.html
55-
// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation
56-
// ^ meta.tag - meta.attribute-with-value
57-
// ^ - meta.tag
54+
// ^^^^^ meta.tag meta.attribute-with-value.directive.html meta.string.html meta.interpolation.html source.js.embedded.html
55+
// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation
56+
// ^ meta.tag - meta.attribute-with-value
57+
// ^ - meta.tag
58+
59+
<p v-attrib='i = 0'>
60+
// ^^^ meta.tag - meta.attribute-with-value
61+
// ^^^^^^^^^ meta.tag meta.attribute-with-value.directive.html - meta.string
62+
// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation
63+
// ^^^^^ meta.tag meta.attribute-with-value.directive.html meta.string.html meta.interpolation.html source.js.embedded.html
64+
// ^ meta.tag meta.attribute-with-value.directive.html meta.string.html - meta.interpolation
65+
// ^ meta.tag - meta.attribute-with-value
66+
// ^ - meta.tag
5867

5968
</html>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy