Skip to content

Commit d62e69c

Browse files
jonatankloskoconnorlay
authored andcommitted
Fix edge cases where expression includes delimiters
1 parent a63c69c commit d62e69c

File tree

6 files changed

+830
-785
lines changed

6 files changed

+830
-785
lines changed

grammar.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,16 @@ module.exports = grammar({
9999
),
100100

101101
_expression_value: ($) =>
102-
choice(/[^{}]+/, seq("{", optional($._expression_value), "}")),
102+
// Note that we alias "{" and "}", so they are not targetted by
103+
// delimiter highlight queries.
104+
choice(
105+
/[^{}]+/,
106+
seq(
107+
alias("{", "left"),
108+
repeat($._expression_value),
109+
alias("}", "right")
110+
)
111+
),
103112

104113
special_attribute: ($) => seq($.special_attribute_name, "=", $.expression),
105114

queries/injections.scm

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,8 @@
2020

2121
; expressions live within HTML tags, and do not need to be combined
2222
; <link href={ Routes.static_path(..) } />
23+
; note that we include children, because expression_value may consist
24+
; of multiple nodes, when the value contains { and }
2325
((expression (expression_value) @injection.content)
24-
(#set! injection.language "elixir"))
26+
(#set! injection.language "elixir")
27+
(#set! injection.include-children))

src/grammar.json

+19-14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node-types.json

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)