This commit is contained in:
agra
2026-02-21 02:25:21 +02:00
parent ff2b2a69ab
commit b02fe37a87
6 changed files with 96 additions and 12 deletions

View File

@@ -164,7 +164,7 @@ pub const Server = struct {
const doc = self.documents.get(file_path) orelse {
return try self.sendResponse(id_json, "null");
};
const sema = doc.sema orelse {
const sema = doc.sema orelse doc.last_good_sema orelse {
return try self.sendResponse(id_json, "null");
};
@@ -420,7 +420,9 @@ pub const Server = struct {
}
// Regular completion: all in-scope symbols + keywords
const sema = doc.sema orelse {
// Fall back to last successful analysis when current parse/analysis fails
// (common while user is mid-typing)
const sema = doc.sema orelse doc.last_good_sema orelse {
return try self.sendResponse(id_json, "[]");
};
@@ -490,7 +492,7 @@ pub const Server = struct {
var items = std.ArrayList(lsp.CompletionItem).empty;
if (extractDotPrefix(doc.source, cursor_offset)) |prefix| {
if (doc.sema) |sema| {
if (doc.sema orelse doc.last_good_sema) |sema| {
// Check if prefix is a namespace — offer imported doc's declarations
if (self.findImportByNs(doc, prefix)) |imp| {
if (self.documents.get(imp.path)) |imp_doc| {