File tree Expand file tree Collapse file tree 2 files changed +21
-9
lines changed
tests/cases/unittests/services Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -4550,17 +4550,16 @@ module ts {
4550
4550
do {
4551
4551
token = scanner . scan ( ) ;
4552
4552
4553
- if ( ( token === SyntaxKind . SlashToken || token === SyntaxKind . SlashEqualsToken ) && ! noRegexTable [ lastNonTriviaToken ] ) {
4554
- if ( scanner . reScanSlashToken ( ) === SyntaxKind . RegularExpressionLiteral ) {
4555
- token = SyntaxKind . RegularExpressionLiteral ;
4553
+ if ( ! isTrivia ( token ) ) {
4554
+ if ( ( token === SyntaxKind . SlashToken || token === SyntaxKind . SlashEqualsToken ) && ! noRegexTable [ lastNonTriviaToken ] ) {
4555
+ if ( scanner . reScanSlashToken ( ) === SyntaxKind . RegularExpressionLiteral ) {
4556
+ token = SyntaxKind . RegularExpressionLiteral ;
4557
+ }
4558
+ }
4559
+ else if ( lastNonTriviaToken === SyntaxKind . DotToken ) {
4560
+ token = SyntaxKind . Identifier ;
4556
4561
}
4557
- }
4558
- else if ( lastNonTriviaToken === SyntaxKind . DotToken ) {
4559
- token = SyntaxKind . Identifier ;
4560
- }
4561
4562
4562
- // Only recall the token if it was *not* trivia.
4563
- if ( ! ( SyntaxKind . FirstTriviaToken <= token && token <= SyntaxKind . LastTriviaToken ) ) {
4564
4563
lastNonTriviaToken = token ;
4565
4564
}
4566
4565
@@ -4612,6 +4611,10 @@ module ts {
4612
4611
result . entries . push ( { length : length , classification : classification } ) ;
4613
4612
}
4614
4613
}
4614
+
4615
+ function isTrivia ( token : SyntaxKind ) {
4616
+ return SyntaxKind . FirstTriviaToken <= token && token <= SyntaxKind . LastTriviaToken ;
4617
+ }
4615
4618
}
4616
4619
4617
4620
function isBinaryExpressionOperatorToken ( token : SyntaxKind ) : boolean {
Original file line number Diff line number Diff line change @@ -189,6 +189,15 @@ describe('Colorization', function () {
189
189
identifier ( "var" ) ) ;
190
190
} ) ;
191
191
192
+ it ( "correctly classifies a keyword after a dot separated by comment trivia" , function ( ) {
193
+ test ( "a./*hello world*/ var" ,
194
+ ts . EndOfLineState . Start ,
195
+ identifier ( "a" ) ,
196
+ punctuation ( "." ) ,
197
+ comment ( "/*hello world*/" ) ,
198
+ identifier ( "var" ) ) ;
199
+ } ) ;
200
+
192
201
it ( "classifies a property access with whitespace around the dot" , function ( ) {
193
202
test ( " x .\tfoo ()" ,
194
203
ts . EndOfLineState . Start ,
You can’t perform that action at this time.
0 commit comments