From 2f13222180dee1cbfac550955d98f2da556b7c8a Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Mon, 6 Nov 2017 18:29:38 -0800 Subject: [PATCH] Handle windows linebreaks in getSourceFileImportLocation --- src/services/utilities.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 36089f94f7..643aae2bae 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -1335,18 +1335,30 @@ namespace ts { let position = 0; // However we should still skip a pinned comment at the top if (ranges.length && ranges[0].kind === SyntaxKind.MultiLineCommentTrivia && isPinnedComment(text, ranges[0])) { - position = ranges[0].end + 1; + position = ranges[0].end; + AdvancePastLineBreak(); ranges = ranges.slice(1); } // As well as any triple slash references for (const range of ranges) { if (range.kind === SyntaxKind.SingleLineCommentTrivia && isRecognizedTripleSlashComment(node.text, range.pos, range.end)) { - position = range.end + 1; + position = range.end; + AdvancePastLineBreak(); continue; } break; } return position; + + function AdvancePastLineBreak() { + if (text.charCodeAt(position) === 0xD) { + position++; + } + + if (text.charCodeAt(position) === 0xA) { + position++; + } + } } /**