mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-23 02:05:42 +00:00
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:
parent
5b866f6d12
commit
49c5b44026
@ -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 =
|
||||
|
Loading…
Reference in New Issue
Block a user