Skip to content

Commit

Permalink
Themes: Fix invalid list/mapping highlighting
Browse files Browse the repository at this point in the history
Fixes #274

Scope unexpected value types more gracefully to avoid breaking syntax
highlighting of the following content.
  • Loading branch information
DeathAxe committed Feb 22, 2020
1 parent a54feb8 commit 3f19748
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Package/Sublime JSON/Sublime JSON.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ contexts:

expect-string-rest:
- include: comments
- match: \{
set:
- meta_scope: invalid.illegal.expected-string.sublime
- include: in-mapping-ignored
- match: \[
set:
- meta_scope: invalid.illegal.expected-string.sublime
- include: in-sequence-ignored
- match: \s*(?=[},\]])
scope: invalid.illegal.expected-string.sublime
pop: true
Expand Down Expand Up @@ -281,6 +289,10 @@ contexts:

expect-sequence-rest:
- include: comments
- match: \{
set:
- meta_scope: invalid.illegal.expected-sequence.sublime
- include: in-mapping-ignored
- match: \s*(?=[},\]])
scope: invalid.illegal.expected-sequence.sublime
pop: true
Expand Down Expand Up @@ -312,6 +324,11 @@ contexts:
- match: \S
scope: invalid.illegal.expected-comma.inside-sequence.json

in-sequence-ignored:
- match: \]
pop: true
- match: \[
push: in-sequence-ignored

#################################################
# Mapping
Expand All @@ -338,6 +355,10 @@ contexts:

expect-mapping-rest:
- include: comments
- match: \[
set:
- meta_scope: invalid.illegal.expected-mapping.sublime
- include: in-sequence-ignored
- match: \s*(?=[},\]])
scope: invalid.illegal.expected-mapping.sublime
pop: true
Expand Down Expand Up @@ -422,6 +443,11 @@ contexts:
- match: ''
pop: true

in-mapping-ignored:
- match: \}
pop: true
- match: \{
push: in-mapping-ignored

#################################################
# Special Values
Expand Down
17 changes: 17 additions & 0 deletions Package/Sublime Text Theme/syntax_test_newstyletheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
// ^^^^^^^^^^ meta.rule-key.attributes.sublime-theme string.quoted.double.json storage.modifier.selector.sublime-theme
// ^ keyword.operator.logical.sublime-theme
// ^^^^^^^^ entity.other.attribute-name.sublime-theme
"parents": [["class": "button_control", "attributes": ["!selected"]]],
// ^^^^^^^ meta.rule-key.parents.sublime-theme string.quoted.double.json storage.modifier.selector.sublime-theme
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.json meta.parents-sequence.sublime-theme
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid.illegal.expected-mapping.sublime
// ^ - invalid
//
"platforms": ["windows", "osx", "linux"],
// ^^^^^^^^^ meta.rule-key.platforms.sublime-theme string.quoted.double.json storage.modifier.selector.sublime-theme
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.sequence.json meta.platforms-sequence.sublime-theme
Expand Down Expand Up @@ -207,6 +213,10 @@
},
"layer0.texture": null,
// ^^^^ constant.language.null.json

"layer0.texture": [255, 255, 255, 255],
// ^^^^^^^^^^^^^^^^^^^^ invalid.illegal.expected-string.sublime
// ^ - invalid
},
{
"class": "scroll_area_control",
Expand Down Expand Up @@ -234,6 +244,13 @@
"right_shadow": "black",
// ^^^^^^^^^^^^ keyword.other.rule.sublime-theme
// ^^^^^ support.constant.color.w3c-standard-color-name.css
"right_shadow": [0, 0, 0, 255],
// ^^^^^^^^^^^^ keyword.other.rule.sublime-theme
// ^^^^^^^^^^^^^^ meta.sequence.json
"right_shadow": {"key": "value"},
// ^^^^^^^^^^^^ keyword.other.rule.sublime-theme
// ^^^^^^^^^^^^^^^^ invalid.illegal.expected-sequence.sublime
// ^ - invalid
"right_shadow_size": 6,
// ^^^^^^^^^^^^^^^^^ keyword.other.rule.sublime-theme
// ^ constant.numeric.json
Expand Down

0 comments on commit 3f19748

Please sign in to comment.