Skip to content

Commit 648a036

Browse files
committed
Update the end of import declaration at the new line as well as end of the line
Fixes #485
1 parent 5ef9065 commit 648a036

File tree

5 files changed

+60
-6
lines changed

5 files changed

+60
-6
lines changed

TypeScript.YAML-tmLanguage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ repository:
343343
'2': { name: keyword.control.import.ts }
344344
'3': { name: variable.other.readwrite.alias.ts }
345345
'4': { name: keyword.operator.assignment.ts }
346-
end: (?=;|$)
346+
end: (?=;|$|^)
347347
patterns:
348348
- include: '#comment'
349349
- match: ([_$[:alpha:]][_$[:alnum:]]*)\s*(\.)
@@ -359,7 +359,7 @@ repository:
359359
beginCaptures:
360360
'1': { name: keyword.control.export.ts }
361361
'2': { name: keyword.control.import.ts }
362-
end: (?=;|$)
362+
end: (?=;|$|^)
363363
patterns:
364364
- include: '#import-export-declaration'
365365

TypeScript.tmLanguage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,7 +1052,7 @@
10521052
</dict>
10531053
</dict>
10541054
<key>end</key>
1055-
<string>(?=;|$)</string>
1055+
<string>(?=;|$|^)</string>
10561056
<key>patterns</key>
10571057
<array>
10581058
<dict>
@@ -1106,7 +1106,7 @@
11061106
</dict>
11071107
</dict>
11081108
<key>end</key>
1109-
<string>(?=;|$)</string>
1109+
<string>(?=;|$|^)</string>
11101110
<key>patterns</key>
11111111
<array>
11121112
<dict>

TypeScriptReact.tmLanguage

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@
10561056
</dict>
10571057
</dict>
10581058
<key>end</key>
1059-
<string>(?=;|$)</string>
1059+
<string>(?=;|$|^)</string>
10601060
<key>patterns</key>
10611061
<array>
10621062
<dict>
@@ -1110,7 +1110,7 @@
11101110
</dict>
11111111
</dict>
11121112
<key>end</key>
1113-
<string>(?=;|$)</string>
1113+
<string>(?=;|$|^)</string>
11141114
<key>patterns</key>
11151115
<array>
11161116
<dict>

tests/baselines/Issue485.baseline.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
original file
2+
-----------------------------------
3+
import a from 'a' // test
4+
import b from 'b'
5+
-----------------------------------
6+
7+
Grammar: TypeScript.tmLanguage
8+
-----------------------------------
9+
>import a from 'a' // test
10+
^^^^^^
11+
source.ts meta.import.ts keyword.control.import.ts
12+
^
13+
source.ts meta.import.ts
14+
^
15+
source.ts meta.import.ts variable.other.readwrite.alias.ts
16+
^
17+
source.ts meta.import.ts
18+
^^^^
19+
source.ts meta.import.ts keyword.control.from.ts
20+
^
21+
source.ts meta.import.ts
22+
^
23+
source.ts meta.import.ts string.quoted.single.ts punctuation.definition.string.begin.ts
24+
^
25+
source.ts meta.import.ts string.quoted.single.ts
26+
^
27+
source.ts meta.import.ts string.quoted.single.ts punctuation.definition.string.end.ts
28+
^
29+
source.ts meta.import.ts
30+
^^
31+
source.ts meta.import.ts comment.line.double-slash.ts punctuation.definition.comment.ts
32+
^^^^^^^
33+
source.ts meta.import.ts comment.line.double-slash.ts
34+
>import b from 'b'
35+
^^^^^^
36+
source.ts meta.import.ts keyword.control.import.ts
37+
^
38+
source.ts meta.import.ts
39+
^
40+
source.ts meta.import.ts variable.other.readwrite.alias.ts
41+
^
42+
source.ts meta.import.ts
43+
^^^^
44+
source.ts meta.import.ts keyword.control.from.ts
45+
^
46+
source.ts meta.import.ts
47+
^
48+
source.ts meta.import.ts string.quoted.single.ts punctuation.definition.string.begin.ts
49+
^
50+
source.ts meta.import.ts string.quoted.single.ts
51+
^
52+
source.ts meta.import.ts string.quoted.single.ts punctuation.definition.string.end.ts

tests/cases/Issue485.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import a from 'a' // test
2+
import b from 'b'

0 commit comments

Comments
 (0)