File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1330,23 +1330,39 @@ namespace ts {
13301330 export function getSourceFileImportLocation ( node : SourceFile ) {
13311331 // For a source file, it is possible there are detached comments we should not skip
13321332 const text = node . text ;
1333+ const textLength = text . length ;
13331334 let ranges = getLeadingCommentRanges ( text , 0 ) ;
13341335 if ( ! ranges ) return 0 ;
13351336 let position = 0 ;
13361337 // However we should still skip a pinned comment at the top
13371338 if ( ranges . length && ranges [ 0 ] . kind === SyntaxKind . MultiLineCommentTrivia && isPinnedComment ( text , ranges [ 0 ] ) ) {
1338- position = ranges [ 0 ] . end + 1 ;
1339+ position = ranges [ 0 ] . end ;
1340+ advancePastLineBreak ( ) ;
13391341 ranges = ranges . slice ( 1 ) ;
13401342 }
13411343 // As well as any triple slash references
13421344 for ( const range of ranges ) {
13431345 if ( range . kind === SyntaxKind . SingleLineCommentTrivia && isRecognizedTripleSlashComment ( node . text , range . pos , range . end ) ) {
1344- position = range . end + 1 ;
1346+ position = range . end ;
1347+ advancePastLineBreak ( ) ;
13451348 continue ;
13461349 }
13471350 break ;
13481351 }
13491352 return position ;
1353+
1354+ function advancePastLineBreak ( ) {
1355+ if ( position < textLength ) {
1356+ const charCode = text . charCodeAt ( position ) ;
1357+ if ( isLineBreak ( charCode ) ) {
1358+ position ++ ;
1359+
1360+ if ( position < textLength && charCode === CharacterCodes . carriageReturn && text . charCodeAt ( position ) === CharacterCodes . lineFeed ) {
1361+ position ++ ;
1362+ }
1363+ }
1364+ }
1365+ }
13501366 }
13511367
13521368 /**
You can’t perform that action at this time.
0 commit comments