From dedb9deb08a13cdf8d21fdc3661b6b054a3f0cc4 Mon Sep 17 00:00:00 2001 From: nullptrdevs <16590917+nullptrdevs@users.noreply.github.com> Date: Wed, 15 Feb 2023 10:33:58 -0800 Subject: [PATCH] Fix handling of invalid tokens in getPositionContext (#1006) --- src/analysis.zig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/analysis.zig b/src/analysis.zig index 344cfce..b1491b0 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -1576,8 +1576,9 @@ pub fn getPositionContext( }, }; } - const q = std.mem.lastIndexOf(u8, held_line, "\"") orelse return .other; - if (held_line[q -| 1] == '@') { + const s = held_line[tok.loc.start..tok.loc.end]; + const q = std.mem.indexOf(u8, s, "\"") orelse return .other; + if (s[q -| 1] == '@') { tok.tag = .identifier; } else { tok.tag = .string_literal;