From c90418c57af09ddc7bd6827895052a6276ef8a9f Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 10 Sep 2018 12:02:14 -0700 Subject: [PATCH] Fix detection of import-export clause when name is $ Fixes #665 --- TypeScript.YAML-tmLanguage | 2 +- TypeScript.tmLanguage | 2 +- TypeScriptReact.tmLanguage | 2 +- tests/baselines/Issue665.baseline.txt | 96 +++++++++++++++++++++++++++ tests/cases/Issue665.ts | 3 + 5 files changed, 102 insertions(+), 3 deletions(-) create mode 100644 tests/baselines/Issue665.baseline.txt create mode 100644 tests/cases/Issue665.ts diff --git a/TypeScript.YAML-tmLanguage b/TypeScript.YAML-tmLanguage index 9ecab4a7..d778239e 100644 --- a/TypeScript.YAML-tmLanguage +++ b/TypeScript.YAML-tmLanguage @@ -1138,7 +1138,7 @@ repository: patterns: - include: '#comment' #(default|*|name) as alias - - match: '{{startOfIdentifier}}(?:(\bdefault)|(\*)|(\b{{identifier}}))\s+(as)\s+(?:(\bdefault{{endOfIdentifier}})|(\b{{identifier}}))' + - match: '{{startOfIdentifier}}(?:(\bdefault)|(\*)|(\b{{identifier}}))\s+(as)\s+(?:(default{{endOfIdentifier}})|({{identifier}}))' captures: '1': { name: keyword.control.default.ts } '2': { name: constant.language.import-export-all.ts } diff --git a/TypeScript.tmLanguage b/TypeScript.tmLanguage index dd29914c..068ad687 100644 --- a/TypeScript.tmLanguage +++ b/TypeScript.tmLanguage @@ -3672,7 +3672,7 @@ match - (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bdefault)|(\*)|(\b[_$[:alpha:]][_$[:alnum:]]*))\s+(as)\s+(?:(\bdefault(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|(\b[_$[:alpha:]][_$[:alnum:]]*)) + (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bdefault)|(\*)|(\b[_$[:alpha:]][_$[:alnum:]]*))\s+(as)\s+(?:(default(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|([_$[:alpha:]][_$[:alnum:]]*)) captures 1 diff --git a/TypeScriptReact.tmLanguage b/TypeScriptReact.tmLanguage index 373a047b..dd89358d 100644 --- a/TypeScriptReact.tmLanguage +++ b/TypeScriptReact.tmLanguage @@ -3676,7 +3676,7 @@ match - (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bdefault)|(\*)|(\b[_$[:alpha:]][_$[:alnum:]]*))\s+(as)\s+(?:(\bdefault(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|(\b[_$[:alpha:]][_$[:alnum:]]*)) + (?<![_$[:alnum:]])(?:(?<=\.\.\.)|(?<!\.))(?:(\bdefault)|(\*)|(\b[_$[:alpha:]][_$[:alnum:]]*))\s+(as)\s+(?:(default(?![_$[:alnum:]])(?:(?=\.\.\.)|(?!\.)))|([_$[:alpha:]][_$[:alnum:]]*)) captures 1 diff --git a/tests/baselines/Issue665.baseline.txt b/tests/baselines/Issue665.baseline.txt new file mode 100644 index 00000000..180c341f --- /dev/null +++ b/tests/baselines/Issue665.baseline.txt @@ -0,0 +1,96 @@ +original file +----------------------------------- +import * as _ from 'lodash'; +import * as $ from 'jquery'; +import * as React from 'react'; +----------------------------------- + +Grammar: TypeScript.tmLanguage +----------------------------------- +>import * as _ from 'lodash'; + ^^^^^^ + source.ts meta.import.ts keyword.control.import.ts + ^ + source.ts meta.import.ts + ^ + source.ts meta.import.ts constant.language.import-export-all.ts + ^ + source.ts meta.import.ts + ^^ + source.ts meta.import.ts keyword.control.as.ts + ^ + source.ts meta.import.ts + ^ + source.ts meta.import.ts variable.other.readwrite.alias.ts + ^ + source.ts meta.import.ts + ^^^^ + source.ts meta.import.ts keyword.control.from.ts + ^ + source.ts meta.import.ts + ^ + source.ts meta.import.ts string.quoted.single.ts punctuation.definition.string.begin.ts + ^^^^^^ + source.ts meta.import.ts string.quoted.single.ts + ^ + source.ts meta.import.ts string.quoted.single.ts punctuation.definition.string.end.ts + ^ + source.ts punctuation.terminator.statement.ts +>import * as $ from 'jquery'; + ^^^^^^ + source.ts meta.import.ts keyword.control.import.ts + ^ + source.ts meta.import.ts + ^ + source.ts meta.import.ts constant.language.import-export-all.ts + ^ + source.ts meta.import.ts + ^^ + source.ts meta.import.ts keyword.control.as.ts + ^ + source.ts meta.import.ts + ^ + source.ts meta.import.ts variable.other.readwrite.alias.ts + ^ + source.ts meta.import.ts + ^^^^ + source.ts meta.import.ts keyword.control.from.ts + ^ + source.ts meta.import.ts + ^ + source.ts meta.import.ts string.quoted.single.ts punctuation.definition.string.begin.ts + ^^^^^^ + source.ts meta.import.ts string.quoted.single.ts + ^ + source.ts meta.import.ts string.quoted.single.ts punctuation.definition.string.end.ts + ^ + source.ts punctuation.terminator.statement.ts +>import * as React from 'react'; + ^^^^^^ + source.ts meta.import.ts keyword.control.import.ts + ^ + source.ts meta.import.ts + ^ + source.ts meta.import.ts constant.language.import-export-all.ts + ^ + source.ts meta.import.ts + ^^ + source.ts meta.import.ts keyword.control.as.ts + ^ + source.ts meta.import.ts + ^^^^^ + source.ts meta.import.ts variable.other.readwrite.alias.ts + ^ + source.ts meta.import.ts + ^^^^ + source.ts meta.import.ts keyword.control.from.ts + ^ + source.ts meta.import.ts + ^ + source.ts meta.import.ts string.quoted.single.ts punctuation.definition.string.begin.ts + ^^^^^ + source.ts meta.import.ts string.quoted.single.ts + ^ + source.ts meta.import.ts string.quoted.single.ts punctuation.definition.string.end.ts + ^ + source.ts punctuation.terminator.statement.ts \ No newline at end of file diff --git a/tests/cases/Issue665.ts b/tests/cases/Issue665.ts new file mode 100644 index 00000000..dca50574 --- /dev/null +++ b/tests/cases/Issue665.ts @@ -0,0 +1,3 @@ +import * as _ from 'lodash'; +import * as $ from 'jquery'; +import * as React from 'react'; \ No newline at end of file