From d9a80b198683e187f61ddf88368eaa2dbed4d7d4 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 12 May 2020 14:27:25 +0200 Subject: [PATCH 1/2] check is ast present --- src/app/compiler/compiler-abstract.js | 4 ++++ src/lib/offsetToLineColumnConverter.js | 16 +++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/app/compiler/compiler-abstract.js b/src/app/compiler/compiler-abstract.js index aa3b1cfaa7..1e18ec1470 100644 --- a/src/app/compiler/compiler-abstract.js +++ b/src/app/compiler/compiler-abstract.js @@ -32,6 +32,10 @@ module.exports = class CompilerAbstract { getSourceName (fileIndex) { if (this.data && this.data.sources) { return Object.keys(this.data.sources)[fileIndex] + } else if (Object.keys(this.source.sources).length === 1) { + // if we don't have ast, we return the only one filename present. + const sourcesArray = Object.keys(this.source.sources) + return sourcesArray[0] } return null } diff --git a/src/lib/offsetToLineColumnConverter.js b/src/lib/offsetToLineColumnConverter.js index 46e192b120..8436706484 100644 --- a/src/lib/offsetToLineColumnConverter.js +++ b/src/lib/offsetToLineColumnConverter.js @@ -19,11 +19,17 @@ export class OffsetToLineColumnConverter extends Plugin { offsetToLineColumn (rawLocation, file, sources, asts) { if (!this.lineBreakPositionsByContent[file]) { - for (var filename in asts) { - var source = asts[filename] - if (source.id === file) { - this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) - break + const sourcesArray = Object.keys(sources) + if (!asts && file === 0 && sourcesArray.length === 1) { + // if we don't have ast, we process the only one available content + this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[sourcesArray[0]].content) + } else { + for (var filename in asts) { + var source = asts[filename] + if (source.id === file) { + this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) + break + } } } } From 09bd187e15fb6c88e538b8650a874c621c7680e0 Mon Sep 17 00:00:00 2001 From: yann300 Date: Thu, 4 Jun 2020 09:21:38 +0200 Subject: [PATCH 2/2] update standard --- src/lib/offsetToLineColumnConverter.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/offsetToLineColumnConverter.js b/src/lib/offsetToLineColumnConverter.js index 8436706484..ed76c7c3b9 100644 --- a/src/lib/offsetToLineColumnConverter.js +++ b/src/lib/offsetToLineColumnConverter.js @@ -25,7 +25,7 @@ export class OffsetToLineColumnConverter extends Plugin { this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[sourcesArray[0]].content) } else { for (var filename in asts) { - var source = asts[filename] + const source = asts[filename] if (source.id === file) { this.lineBreakPositionsByContent[file] = this.sourceMappingDecoder.getLinebreakPositions(sources[filename].content) break