From bba3c35798ebfa7df3f6699e5ddab69e03876c90 Mon Sep 17 00:00:00 2001 From: DeathAxe Date: Sat, 22 Feb 2020 11:19:51 +0100 Subject: [PATCH] Themes: Fix invalid list/mapping highlighting Fixes #274 Scope unexpected value types more gracefully to avoid breaking syntax highlighting of the following content. --- .../Sublime JSON/Sublime JSON.sublime-syntax | 26 +++++++++++++++++++ .../Sublime Text Menu/syntax_test_menu.json | 7 ++--- .../syntax_test_newstyletheme.json | 17 ++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Package/Sublime JSON/Sublime JSON.sublime-syntax b/Package/Sublime JSON/Sublime JSON.sublime-syntax index df0425cf..7e4f9c90 100644 --- a/Package/Sublime JSON/Sublime JSON.sublime-syntax +++ b/Package/Sublime JSON/Sublime JSON.sublime-syntax @@ -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 @@ -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 @@ -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 @@ -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 @@ -422,6 +443,11 @@ contexts: - match: '' pop: true + in-mapping-ignored: + - match: \} + pop: true + - match: \{ + push: in-mapping-ignored ################################################# # Special Values diff --git a/Package/Sublime Text Menu/syntax_test_menu.json b/Package/Sublime Text Menu/syntax_test_menu.json index 09e0b7b1..b435c1d4 100644 --- a/Package/Sublime Text Menu/syntax_test_menu.json +++ b/Package/Sublime Text Menu/syntax_test_menu.json @@ -28,11 +28,8 @@ "id": ["file"], // ^^^^ meta.mapping.key.json meta.main-key.sublime-menu string.quoted.double.json // ^^ keyword.other.main.sublime-menu -// ^ invalid.illegal.expected-string.sublime -// ^^^^^^ meta.id.sublime-menu -// ^^^^ entity.name.id.sublime-menu -// ^ invalid.illegal.expected-comma - invalid.illegal.expected-string.sublime -// ^ punctuation.separator.mapping.pair.json +// ^^^^^^^^ invalid.illegal.expected-string.sublime +// ^ punctuation.separator.mapping.pair.json - invalid "children" : // ^^^^^^^^^^ meta.mapping.key.json meta.main-key.sublime-menu string.quoted.double.json // ^^^^^^^^ keyword.other.main.sublime-menu diff --git a/Package/Sublime Text Theme/syntax_test_newstyletheme.json b/Package/Sublime Text Theme/syntax_test_newstyletheme.json index f38c4953..9dfe940c 100644 --- a/Package/Sublime Text Theme/syntax_test_newstyletheme.json +++ b/Package/Sublime Text Theme/syntax_test_newstyletheme.json @@ -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 @@ -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", @@ -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