Bug 1559583 Part 2 - Pad source contents with blank lines when they don't start at line 1, r=loganfsmyth.

Depends on D40911

Differential Revision: https://phabricator.services.mozilla.com/D40912

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brian Hackett 2019-08-21 23:58:32 +00:00
Родитель 5b866f6d12
Коммит 49c5b44026
1 изменённых файлов: 11 добавлений и 8 удалений

Просмотреть файл

@ -240,7 +240,16 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
(this._contentType.includes("javascript") ||
this._contentType === "text/wasm")
) {
return toResolvedContent(this._source.text);
// If the source doesn't start at line 1, line numbers in the client will
// not match up with those in the source. Pad the text with blank lines to
// fix this. This can show up for sources associated with inline scripts
// in HTML created via document.write() calls: the script's source line
// number is relative to the start of the written HTML, but we show the
// source's content by itself.
const padding = this._source.startLine
? "\n".repeat(this._source.startLine - 1)
: "";
return toResolvedContent(padding + this._source.text);
}
const result = await this.sources.htmlFileContents(
@ -305,13 +314,7 @@ const SourceActor = ActorClassWithSpec(sourceSpec, {
},
_calculateStartLineColumnDisplacement(fileContents) {
const scripts = this._findDebuggeeScripts();
if (!scripts.length) {
return {};
}
const sorted = scripts.sort((a, b) => b.startLine < a.startLine);
const startLine = sorted[0].startLine;
const startLine = this._source.startLine;
const lineBreak = /\r\n?|\n|\u2028|\u2029/;
const fileStartLine =