Fix handling of invalid tokens in getPositionContext (#1006)

This commit is contained in:
nullptrdevs 2023-02-15 10:33:58 -08:00 committed by GitHub
parent 2071db440d
commit dedb9deb08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1576,8 +1576,9 @@ pub fn getPositionContext(
}, },
}; };
} }
const q = std.mem.lastIndexOf(u8, held_line, "\"") orelse return .other; const s = held_line[tok.loc.start..tok.loc.end];
if (held_line[q -| 1] == '@') { const q = std.mem.indexOf(u8, s, "\"") orelse return .other;
if (s[q -| 1] == '@') {
tok.tag = .identifier; tok.tag = .identifier;
} else { } else {
tok.tag = .string_literal; tok.tag = .string_literal;