mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
Add bailout case to sourcemap searching code (#25212)
* Add bailout case to sourcemap searching code * Also skip sourcemappy comments like sourceURL
This commit is contained in:
parent
3a023ed7d6
commit
297f12e92c
@ -1510,7 +1510,8 @@ namespace ts {
|
||||
}
|
||||
|
||||
// Sometimes tools can sometimes see the following line as a source mapping url comment, so we mangle it a bit (the [M])
|
||||
const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/gm;
|
||||
const sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)$/;
|
||||
const whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
|
||||
const base64UrlRegExp = /^data:(?:application\/json(?:;charset=[uU][tT][fF]-8);base64,([A-Za-z0-9+\/=]+)$)?/;
|
||||
function scanForSourcemapURL(fileName: string) {
|
||||
const mappedFile = sourcemappedFileCache.get(toPath(fileName, currentDirectory, getCanonicalFileName));
|
||||
@ -1519,11 +1520,15 @@ namespace ts {
|
||||
}
|
||||
const starts = getLineStarts(mappedFile);
|
||||
for (let index = starts.length - 1; index >= 0; index--) {
|
||||
sourceMapCommentRegExp.lastIndex = starts[index];
|
||||
const comment = sourceMapCommentRegExp.exec(mappedFile.text);
|
||||
const lineText = mappedFile.text.substring(starts[index], starts[index + 1]);
|
||||
const comment = sourceMapCommentRegExp.exec(lineText);
|
||||
if (comment) {
|
||||
return comment[1];
|
||||
}
|
||||
// If we see a nonwhitespace/map comment-like line, break, to avoid scanning up the entire file
|
||||
else if (!lineText.match(whitespaceOrMapCommentRegExp)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
583712
tests/cases/fourslash/reallyLargeFile.ts
Normal file
583712
tests/cases/fourslash/reallyLargeFile.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -1 +1 @@
|
||||
Subproject commit 6b9706810b55af326a93b9aa59cb17815a30bb32
|
||||
Subproject commit 40bdb4eadabc9fbed7d83e3f26817a931c0763b6
|
||||
Loading…
x
Reference in New Issue
Block a user