Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5988 from lwedge99/fix/source-map
Browse files Browse the repository at this point in the history
fix source map with multibyte characters
  • Loading branch information
haltman-at committed Apr 12, 2023
2 parents 33f2bc2 + 0ee863d commit 2af9923
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/source-map-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@ var SourceMapUtils = {
var column = 0;

source.forEach(function (character) {
let loc = { line, column };
if (character === "\n") {
line += 1;
column = -1;

mapping.push({
loc = {
line: line,
column: 0
});
} else {
mapping.push({
line: line,
column: column
});
};
}

for (let i = 0; i < Buffer.from(character).length; i++) {
//because our character offsets here are in bytes, we need to
//pad out the line/column map as per the UTF-8 length of the
//characters so we're mapping *bytes* to line/columns
mapping.push(loc);
}
column += 1;
});

Expand Down

0 comments on commit 2af9923

Please sign in to comment.