From d974b80295bda91dac1c15f27a6c2863bbfa35fb Mon Sep 17 00:00:00 2001 From: aleclarson Date: Thu, 14 Jun 2018 20:52:09 -0400 Subject: [PATCH] overwrite segments for removed code Not sure how useful this is yet. --- src/utils/Mappings.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/utils/Mappings.js b/src/utils/Mappings.js index bf872eb..3dbae42 100644 --- a/src/utils/Mappings.js +++ b/src/utils/Mappings.js @@ -27,12 +27,20 @@ export default class Mappings { let originalCharIndex = chunk.start; let first = true; + let len = this.rawSegments.length; while (originalCharIndex < chunk.end) { if (this.hires || first || sourcemapLocations[originalCharIndex]) { - this.rawSegments.push([this.generatedCodeColumn, sourceIndex, loc.line, loc.column]); + if (len !== 0) { + const segment = this.rawSegments[len - 1]; + if (segment[0] === this.generatedCodeColumn) { + len -= 1; // overwrite segments for removed code + } + } + this.rawSegments[len++] = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column]; } if (original[originalCharIndex] === '\n') { + len = 0; loc.line += 1; loc.column = 0; this.generatedCodeLine += 1;