diff options
author | 2021-09-20 18:04:45 -0700 | |
---|---|---|
committer | 2021-09-20 18:04:45 -0700 | |
commit | 90cd3bf4cbe06b1795cd47bcae670d5970564abd (patch) | |
tree | 85efc5b6731963ed28bb005f9b7112ec5f037fae /src/string_immutable.zig | |
parent | 9752ee881939674543d3166e9f037287864b6f34 (diff) | |
download | bun-90cd3bf4cbe06b1795cd47bcae670d5970564abd.tar.gz bun-90cd3bf4cbe06b1795cd47bcae670d5970564abd.tar.zst bun-90cd3bf4cbe06b1795cd47bcae670d5970564abd.zip |
Fix how error lines with strings are highlighted
Diffstat (limited to '')
-rw-r--r-- | src/string_immutable.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/string_immutable.zig b/src/string_immutable.zig index 83719571b..564a4f94d 100644 --- a/src/string_immutable.zig +++ b/src/string_immutable.zig @@ -679,6 +679,27 @@ pub const CodepointIterator = struct { } } + pub fn scanUntilQuotedValueOrEOF(iter: *CodepointIterator, comptime quote: CodePoint) usize { + @setRuntimeSafety(false); + + while (iter.c > -1) { + if (!switch (iter.nextCodepoint()) { + quote => false, + '\\' => brk: { + if (iter.nextCodepoint() == quote) { + continue; + } + break :brk true; + }, + else => true, + }) { + return iter.i + 1; + } + } + + return iter.i; + } + pub fn nextCodepoint(it: *CodepointIterator) CodePoint { const slice = it.nextCodepointSlice(); it.width = @intCast(u3, slice.len); |