From ca738a95361949a885a8cbcd15553d40c36310de Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 23 May 2017 12:18:33 +0300 Subject: [PATCH] Prevent JS source map builder from inserting overlapping mappings Check if newly inserted mapping is in the same position within JS line and in this case omit the mapping --- .../kotlin/js/sourceMap/SourceMap3Builder.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/js/js.translator/src/org/jetbrains/kotlin/js/sourceMap/SourceMap3Builder.java b/js/js.translator/src/org/jetbrains/kotlin/js/sourceMap/SourceMap3Builder.java index 698890b2312..07b601bd6f8 100644 --- a/js/js.translator/src/org/jetbrains/kotlin/js/sourceMap/SourceMap3Builder.java +++ b/js/js.translator/src/org/jetbrains/kotlin/js/sourceMap/SourceMap3Builder.java @@ -127,14 +127,19 @@ public class SourceMap3Builder implements SourceMapBuilder { @Override public void addMapping(String source, int sourceLine, int sourceColumn) { - if (previousGeneratedColumn == -1) { + boolean newGroupStarted = previousGeneratedColumn == -1; + if (newGroupStarted) { previousGeneratedColumn = 0; } - else { - out.append(','); - } int columnDiff = textOutput.getColumn() - previousGeneratedColumn; + if (!newGroupStarted && columnDiff == 0) { + return; + } + if (!newGroupStarted) { + out.append(','); + } + // TODO fix sections overlapping // assert columnDiff != 0; Base64VLQ.encode(out, columnDiff);