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
This commit is contained in:
Alexey Andreev
2017-05-23 12:18:33 +03:00
parent 174068c462
commit ca738a9536
@@ -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);