diff options
Diffstat (limited to 'src/sourcemap/sourcemap.zig')
-rw-r--r-- | src/sourcemap/sourcemap.zig | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/sourcemap/sourcemap.zig b/src/sourcemap/sourcemap.zig index b7441ccc9..cc557caf1 100644 --- a/src/sourcemap/sourcemap.zig +++ b/src/sourcemap/sourcemap.zig @@ -356,17 +356,16 @@ pub const LineColumnOffset = struct { std.debug.assert(i >= offset); std.debug.assert(i < input.len); - offset = i + 1; + var iter = strings.CodepointIterator.initOffset(input, i); + var cursor = strings.CodepointIterator.Cursor{ .i = @truncate(u32, iter.i) }; + _ = iter.next(&cursor); + offset = i + cursor.width; - var cp = strings.CodepointIterator.initOffset(input, offset); - var cursor = strings.CodepointIterator.Cursor{}; - _ = cp.next(&cursor); switch (cursor.c) { '\r', '\n', 0x2028, 0x2029 => { // Handle Windows-specific "\r\n" newlines - if (cp.c == '\r' and input.len > offset + 1 and input[offset + 1] == '\n') { + if (cursor.c == '\r' and input.len > i + 1 and input[i + 1] == '\n') { columns += 1; - offset += 1; continue; } |