Skip to content

Commit

Permalink
Handle new line in variable initializer when expression ends with arr…
Browse files Browse the repository at this point in the history
…ow operator

Fixes #702
  • Loading branch information
sheetalkamat committed Jan 3, 2019
1 parent 9f36bf2 commit f17fefd
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion TypeScript.YAML-tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ repository:
variable-initializer:
patterns:
# if it is assignment with expression on same line, use end of line as end of scope
- begin: (?<!=|!)(=)(?!=)(?=\s*\S)
- begin: (?<!=|!)(=)(?!=)(?=\s*\S)(?!\s*.*=>\s*$)
beginCaptures:
'1': { name: keyword.operator.assignment.ts }
end: (?=$|^|[,);}\]]|(\s+(of|in)\s+))
Expand Down
2 changes: 1 addition & 1 deletion TypeScript.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1994,7 +1994,7 @@
<array>
<dict>
<key>begin</key>
<string>(?&lt;!=|!)(=)(?!=)(?=\s*\S)</string>
<string>(?&lt;!=|!)(=)(?!=)(?=\s*\S)(?!\s*.*=&gt;\s*$)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down
2 changes: 1 addition & 1 deletion TypeScriptReact.tmLanguage
Original file line number Diff line number Diff line change
Expand Up @@ -1998,7 +1998,7 @@
<array>
<dict>
<key>begin</key>
<string>(?&lt;!=|!)(=)(?!=)(?=\s*\S)</string>
<string>(?&lt;!=|!)(=)(?!=)(?=\s*\S)(?!\s*.*=&gt;\s*$)</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
Expand Down
36 changes: 36 additions & 0 deletions tests/baselines/Issue702.baseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
original file
-----------------------------------
const t = () =>
`a`
-----------------------------------

Grammar: TypeScript.tmLanguage
-----------------------------------
>const t = () =>
^^^^^
source.ts meta.var.expr.ts storage.type.ts
^
source.ts meta.var.expr.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts meta.definition.variable.ts variable.other.constant.ts entity.name.function.ts
^
source.ts meta.var.expr.ts meta.var-single-variable.expr.ts
^
source.ts meta.var.expr.ts keyword.operator.assignment.ts
^
source.ts meta.var.expr.ts meta.arrow.ts
^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts punctuation.definition.parameters.begin.ts
^
source.ts meta.var.expr.ts meta.arrow.ts meta.parameters.ts punctuation.definition.parameters.end.ts
^
source.ts meta.var.expr.ts meta.arrow.ts
^^
source.ts meta.var.expr.ts meta.arrow.ts storage.type.function.arrow.ts
>`a`
^
source.ts meta.var.expr.ts string.template.ts punctuation.definition.string.template.begin.ts
^
source.ts meta.var.expr.ts string.template.ts
^
source.ts meta.var.expr.ts string.template.ts punctuation.definition.string.template.end.ts
2 changes: 2 additions & 0 deletions tests/cases/Issue702.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const t = () =>
`a`

0 comments on commit f17fefd

Please sign in to comment.