Amend getPositionContext to handle incomplete .string_literals, ie ", @" (#997)

This commit is contained in:
nullptrdevs 2023-02-13 14:47:57 -08:00 committed by GitHub
parent 7919da5054
commit 409c203317
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1557,7 +1557,7 @@ pub fn getPositionContext(
}; };
while (true) { while (true) {
const tok = tokenizer.next(); var tok = tokenizer.next();
// Early exits. // Early exits.
if (tok.loc.start > new_index) break; if (tok.loc.start > new_index) break;
if (tok.loc.start == new_index) { 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, .doc_comment, .container_doc_comment => return .comment,
.eof => break, .eof => break,