From 409c2033178dc85976bc050e04baa7dfbd642f7a Mon Sep 17 00:00:00 2001 From: nullptrdevs <16590917+nullptrdevs@users.noreply.github.com> Date: Mon, 13 Feb 2023 14:47:57 -0800 Subject: [PATCH] Amend `getPositionContext` to handle incomplete `.string_literal`s, ie `"`, `@"` (#997) --- src/analysis.zig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/analysis.zig b/src/analysis.zig index 5c8bf65..b9f39b1 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -1557,7 +1557,7 @@ pub fn getPositionContext( }; while (true) { - const tok = tokenizer.next(); + var tok = tokenizer.next(); // Early exits. if (tok.loc.start > new_index) break; if (tok.loc.start == new_index) { @@ -1576,7 +1576,12 @@ pub fn getPositionContext( }, }; } - return .other; + const q = std.mem.lastIndexOf(u8, held_line, "\"") orelse return .other; + if (held_line[q - 1] == '@') { + tok.tag = .identifier; + } else { + tok.tag = .string_literal; + } }, .doc_comment, .container_doc_comment => return .comment, .eof => break,