From 7cb462dcf4ee707957c9e8dc942c44429615939e Mon Sep 17 00:00:00 2001 From: thom Date: Mon, 15 Oct 2018 15:54:45 -0400 Subject: [PATCH] [JavaScript] Improve arrow function fallback behavior --- JavaScript/JavaScript.sublime-syntax | 6 ++++++ JavaScript/tests/syntax_test_js.js | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/JavaScript/JavaScript.sublime-syntax b/JavaScript/JavaScript.sublime-syntax index ca23a739c0..e9ae9a170a 100644 --- a/JavaScript/JavaScript.sublime-syntax +++ b/JavaScript/JavaScript.sublime-syntax @@ -1499,6 +1499,12 @@ contexts: scope: punctuation.separator.key-value.js push: expression-no-comma + # In case we're inside a destructured arrow function parameter that we + # misidentified as an object literal. + - match: '=' + scope: keyword.operator.assignment.js + push: expression-no-comma + bare-property-name: - match: '{{dollar_only_identifier}}' scope: meta.object-literal.key.dollar.only.js punctuation.dollar.js diff --git a/JavaScript/tests/syntax_test_js.js b/JavaScript/tests/syntax_test_js.js index 00f2f6af5d..50c8a15ae2 100644 --- a/JavaScript/tests/syntax_test_js.js +++ b/JavaScript/tests/syntax_test_js.js @@ -1080,6 +1080,16 @@ const test = ({a, b, c=()=>({active:false}) }) => {}; // ^^^^^^ keyword.control.flow ); +({ + a = {}, +// ^ keyword.operator.assignment +// ^^ punctuation.section.block +// ^ punctuation.separator.comma - keyword.operator.comma + b, +// ^ punctuation.separator.comma - keyword.operator.comma +}) => null; +// ^^ storage.type.function.arrow + MyClass.foo = function() {} // ^^^^^^^^^^^^^^^^^^^^^ meta.function.declaration // ^ support.class