fix cimport duplicate messages & crash (#828)
This commit is contained in:
parent
68ac6f9f30
commit
e1973afafc
@ -317,7 +317,11 @@ fn garbageCollectionCImports(self: *DocumentStore) error{OutOfMemory}!void {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
var kv = self.cimports.fetchSwapRemove(hash).?;
|
var kv = self.cimports.fetchSwapRemove(hash).?;
|
||||||
std.log.debug("Destroying cimport {s}", .{kv.value.success});
|
const message = switch (kv.value) {
|
||||||
|
.failure => "",
|
||||||
|
.success => |uri| uri,
|
||||||
|
};
|
||||||
|
std.log.debug("Destroying cimport {s}", .{message});
|
||||||
kv.value.deinit(self.allocator);
|
kv.value.deinit(self.allocator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,26 +180,6 @@ fn publishDiagnostics(server: *Server, writer: anytype, handle: DocumentStore.Ha
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
for (handle.cimports.items(.hash)) |hash, i| {
|
|
||||||
const result = server.document_store.cimports.get(hash) orelse continue;
|
|
||||||
if (result != .failure) continue;
|
|
||||||
const stderr = std.mem.trim(u8, result.failure, " ");
|
|
||||||
|
|
||||||
var pos_and_diag_iterator = std.mem.split(u8, stderr, ":");
|
|
||||||
_ = pos_and_diag_iterator.next(); // skip file path
|
|
||||||
_ = pos_and_diag_iterator.next(); // skip line
|
|
||||||
_ = pos_and_diag_iterator.next(); // skip character
|
|
||||||
|
|
||||||
const node = handle.cimports.items(.node)[i];
|
|
||||||
try diagnostics.append(allocator, .{
|
|
||||||
.range = offsets.nodeToRange(handle.tree, node, server.offset_encoding),
|
|
||||||
.severity = .Error,
|
|
||||||
.code = "cImport",
|
|
||||||
.source = "zls",
|
|
||||||
.message = try allocator.dupe(u8, pos_and_diag_iterator.rest()),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (server.config.enable_ast_check_diagnostics and tree.errors.len == 0) {
|
if (server.config.enable_ast_check_diagnostics and tree.errors.len == 0) {
|
||||||
try getAstCheckDiagnostics(server, handle, &diagnostics);
|
try getAstCheckDiagnostics(server, handle, &diagnostics);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user