refactor: add file watcher to project_manager and watch project
This commit is contained in:
parent
9cb2e7bc35
commit
b4d2998425
1 changed files with 4 additions and 0 deletions
|
|
@ -3,6 +3,7 @@ const tp = @import("thespian");
|
|||
const cbor = @import("cbor");
|
||||
const log = @import("log");
|
||||
const tracy = @import("tracy");
|
||||
const file_watcher = @import("file_watcher");
|
||||
const file_type_config = @import("file_type_config");
|
||||
const lsp_config = @import("lsp_config");
|
||||
const root = @import("soft_root").root;
|
||||
|
|
@ -520,6 +521,7 @@ const Process = struct {
|
|||
self.logger.print("{s} error: {s}", .{ tag, message });
|
||||
} else if (try cbor.match(m.buf, .{"shutdown"})) {
|
||||
self.persist_projects();
|
||||
file_watcher.shutdown();
|
||||
from.send(.{ "project_manager", "shutdown" }) catch return error.ClientFailed;
|
||||
return error.ExitNormal;
|
||||
} else if (try cbor.match(m.buf, .{ "exit", "normal" })) {
|
||||
|
|
@ -548,6 +550,7 @@ const Process = struct {
|
|||
try self.projects.put(self.allocator, try self.allocator.dupe(u8, project_directory), project);
|
||||
self.restore_project(project) catch |e| self.logger.err("restore_project", e);
|
||||
project.query_git();
|
||||
file_watcher.watch(project_directory) catch |e| self.logger.err("file_watcher.watch", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -558,6 +561,7 @@ const Process = struct {
|
|||
kv.value.deinit();
|
||||
self.allocator.destroy(kv.value);
|
||||
self.logger.print("closed: {s}", .{project_directory});
|
||||
file_watcher.unwatch(project_directory) catch |e| self.logger.err("file_watcher.unwatch", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue