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,6 +1330,7 @@ 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 ;
@@ -1351,12 +1352,15 @@ namespace ts {
13511352 return position ;
13521353
13531354 function AdvancePastLineBreak ( ) {
1354- if ( text . charCodeAt ( position ) === CharacterCodes . carriageReturn ) {
1355- position ++ ;
1356- }
1355+ if ( position < textLength ) {
1356+ const charCode = text . charCodeAt ( position ) ;
1357+ if ( isLineBreak ( charCode ) ) {
1358+ position ++ ;
13571359
1358- if ( text . charCodeAt ( position ) === CharacterCodes . lineFeed ) {
1359- position ++ ;
1360+ if ( position < textLength && charCode === CharacterCodes . carriageReturn && text . charCodeAt ( position ) === CharacterCodes . lineFeed ) {
1361+ position ++ ;
1362+ }
1363+ }
13601364 }
13611365 }
13621366 }
You can’t perform that action at this time.
0 commit comments