Only refresh packages when saving a build.zig file, not on any change
This commit is contained in:
parent
ef95c76e45
commit
9392c4032c
@ -410,6 +410,19 @@ fn refreshDocument(self: *DocumentStore, handle: *Handle, zig_lib_path: ?[]const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn applySave(self: *DocumentStore, handle: *Handle) !void {
|
||||||
|
if (handle.is_build_file) |build_file| {
|
||||||
|
loadPackages(.{
|
||||||
|
.build_file = build_file,
|
||||||
|
.allocator = self.allocator,
|
||||||
|
.build_runner_path = self.build_runner_path,
|
||||||
|
.zig_exe_path = self.zig_exe_path.?,
|
||||||
|
}) catch |err| {
|
||||||
|
std.debug.warn("Failed to load packages of build file {} (error: {})\n", .{ build_file.uri, err });
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn applyChanges(
|
pub fn applyChanges(
|
||||||
self: *DocumentStore,
|
self: *DocumentStore,
|
||||||
handle: *Handle,
|
handle: *Handle,
|
||||||
@ -469,16 +482,6 @@ pub fn applyChanges(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try self.refreshDocument(handle, zig_lib_path);
|
try self.refreshDocument(handle, zig_lib_path);
|
||||||
if (handle.is_build_file) |build_file| {
|
|
||||||
loadPackages(.{
|
|
||||||
.build_file = build_file,
|
|
||||||
.allocator = self.allocator,
|
|
||||||
.build_runner_path = self.build_runner_path,
|
|
||||||
.zig_exe_path = self.zig_exe_path.?,
|
|
||||||
}) catch |err| {
|
|
||||||
std.debug.warn("Failed to load packages of build file {} (error: {})\n", .{ build_file.uri, err });
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn uriFromImportStr(
|
pub fn uriFromImportStr(
|
||||||
|
11
src/main.zig
11
src/main.zig
@ -742,7 +742,16 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v
|
|||||||
const local_config = configFromUriOr(uri, config);
|
const local_config = configFromUriOr(uri, config);
|
||||||
try document_store.applyChanges(handle, content_changes, local_config.zig_lib_path);
|
try document_store.applyChanges(handle, content_changes, local_config.zig_lib_path);
|
||||||
try publishDiagnostics(handle.*, local_config);
|
try publishDiagnostics(handle.*, local_config);
|
||||||
} else if (std.mem.eql(u8, method, "textDocument/didSave") or std.mem.eql(u8, method, "textDocument/willSave")) {
|
} else if (std.mem.eql(u8, method, "textDocument/didSave")) {
|
||||||
|
const text_document = params.getValue("textDocument").?.Object;
|
||||||
|
const uri = text_document.getValue("uri").?.String;
|
||||||
|
const handle = document_store.getHandle(uri) orelse {
|
||||||
|
std.debug.warn("Trying to save non existent document {}", .{uri});
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
try document_store.applySave(handle);
|
||||||
|
} else if (std.mem.eql(u8, method, "textDocument/willSave")) {
|
||||||
// noop
|
// noop
|
||||||
} else if (std.mem.eql(u8, method, "textDocument/didClose")) {
|
} else if (std.mem.eql(u8, method, "textDocument/didClose")) {
|
||||||
const document = params.getValue("textDocument").?.Object;
|
const document = params.getValue("textDocument").?.Object;
|
||||||
|
Loading…
Reference in New Issue
Block a user