From f6124aec3a197dd57148756a78f880a7bed33c8f Mon Sep 17 00:00:00 2001 From: Thom Smith Date: Mon, 12 Apr 2021 11:13:29 -0400 Subject: [PATCH 1/2] [JSX] Improve commenting behavior. --- JavaScript/JSX Comments.tmPreferences | 2 +- JavaScript/JSX.sublime-syntax | 29 +++++++++++++++++++++++++-- JavaScript/tests/syntax_test_jsx.jsx | 24 +++++++++++++++++++--- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/JavaScript/JSX Comments.tmPreferences b/JavaScript/JSX Comments.tmPreferences index e62e1b10a4..931ca99091 100644 --- a/JavaScript/JSX Comments.tmPreferences +++ b/JavaScript/JSX Comments.tmPreferences @@ -5,7 +5,7 @@ name JSX Comments scope - source.jsx meta.jsx - source.jsx.embedded.jsx, source.tsx meta.jsx - source.tsx.embedded.jsx + source.jsx meta.jsx - source.jsx.embedded.jsx - meta.tag.attributes - meta.tag.name, source.tsx meta.jsx - source.tsx.embedded.jsx - meta.tag.attributes - meta.tag.name settings shellVariables diff --git a/JavaScript/JSX.sublime-syntax b/JavaScript/JSX.sublime-syntax index f9c694b24b..235f7cff52 100644 --- a/JavaScript/JSX.sublime-syntax +++ b/JavaScript/JSX.sublime-syntax @@ -18,9 +18,34 @@ contexts: - include: jsx-tag jsx-interpolation: + - match: (?={/\*) + branch_point: jsx-interpolation-comment + branch: + - jsx-interpolation-comment + - jsx-interpolation-plain + - match: (?={) + push: jsx-interpolation-plain + + jsx-interpolation-comment: + - match: '({)(/\*)' + captures: + 1: punctuation.definition.interpolation.begin.js + 2: punctuation.definition.comment.begin.js + set: + - meta_include_prototype: false + - meta_scope: meta.interpolation.js comment.block.js + - match: '(\*/)(})' + captures: + 1: punctuation.definition.comment.end.js + 2: punctuation.definition.interpolation.end.js + pop: true + - match: (?=\*/) + fail: jsx-interpolation-comment + + jsx-interpolation-plain: - match: '{' scope: punctuation.definition.interpolation.begin.js - push: + set: - - meta_scope: meta.interpolation.js - meta_content_scope: source.js.embedded.jsx - match: '}' @@ -62,7 +87,7 @@ contexts: - jsx-tag-name jsx-tag-attributes: - - meta_scope: meta.tag.js + - meta_scope: meta.tag.attributes.js - match: '>' scope: punctuation.definition.tag.end.js diff --git a/JavaScript/tests/syntax_test_jsx.jsx b/JavaScript/tests/syntax_test_jsx.jsx index 55a83c9287..c5a4e366d3 100644 --- a/JavaScript/tests/syntax_test_jsx.jsx +++ b/JavaScript/tests/syntax_test_jsx.jsx @@ -71,7 +71,7 @@ ; ; From 5612aafe66dbb5d3beb6cca0ff7739295686fa89 Mon Sep 17 00:00:00 2001 From: Thom Smith Date: Thu, 15 Apr 2021 16:24:15 -0400 Subject: [PATCH 2/2] [JSX] Simplify comments files. --- JavaScript/Comments.tmPreferences | 2 +- JavaScript/JSX Comments.tmPreferences | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/JavaScript/Comments.tmPreferences b/JavaScript/Comments.tmPreferences index 939619f676..71a87cf1dc 100644 --- a/JavaScript/Comments.tmPreferences +++ b/JavaScript/Comments.tmPreferences @@ -2,7 +2,7 @@ scope - source.js, source.jsx, source.ts, source.tsx + source.js, source.jsx, source.ts, source.tsx, meta.jsx meta.tag.name, meta.jsx meta.tag.attributes settings shellVariables diff --git a/JavaScript/JSX Comments.tmPreferences b/JavaScript/JSX Comments.tmPreferences index 931ca99091..f1239d3772 100644 --- a/JavaScript/JSX Comments.tmPreferences +++ b/JavaScript/JSX Comments.tmPreferences @@ -5,7 +5,7 @@ name JSX Comments scope - source.jsx meta.jsx - source.jsx.embedded.jsx - meta.tag.attributes - meta.tag.name, source.tsx meta.jsx - source.tsx.embedded.jsx - meta.tag.attributes - meta.tag.name + meta.jsx settings shellVariables