fix: watch all directories within the project tree

This commit is contained in:
CJ van den Berg 2026-02-20 10:23:15 +01:00
parent 682188f704
commit c46d910c87
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
3 changed files with 40 additions and 10 deletions

View file

@ -425,6 +425,10 @@ const Process = struct {
if (try cbor.match(m.buf, .{ "FW", "change", tp.extract(&path), tp.extract(&event_type) })) {
self.handle_file_watch_event(path, event_type);
} else if (try cbor.match(m.buf, .{ "walk_tree_dir", tp.extract(&project_directory), tp.extract(&path) })) {
var abs_buf: [std.fs.max_path_bytes]u8 = undefined;
const abs_path = std.fmt.bufPrint(&abs_buf, "{s}{c}{s}", .{ project_directory, std.fs.path.sep, path }) catch return;
file_watcher.watch(abs_path) catch |e| self.logger.err("file_watcher.watch_dir", e);
} else if (try cbor.match(m.buf, .{ "walk_tree_entry", tp.extract(&project_directory), tp.more })) {
if (self.projects.get(project_directory)) |project|
project.walk_tree_entry(m) catch |e| self.logger.err("walk_tree_entry", e);
@ -440,6 +444,15 @@ const Process = struct {
} else if (try cbor.match(m.buf, .{ "git", tp.extract(&context), "blame", tp.more })) {
const request: *Project.GitBlameRequest = @ptrFromInt(context);
request.project.process_git_response(self.parent.ref(), m) catch |e| self.logger.err("git-blame", e);
} else if (try cbor.match(m.buf, .{ "git", tp.extract(&context), "workspace_files", tp.extract(&path) })) {
const project: *Project = @ptrFromInt(context);
const dir_path = std.fs.path.dirname(path) orelse "";
if (dir_path.len > 0) blk: {
var abs_buf: [std.fs.max_path_bytes]u8 = undefined;
const abs_path = std.fmt.bufPrint(&abs_buf, "{s}{c}{s}", .{ project.name, std.fs.path.sep, dir_path }) catch break :blk;
file_watcher.watch(abs_path) catch |e| self.logger.err("file_watcher.watch_dir", e);
}
project.process_git(self.parent.ref(), m) catch {};
} else if (try cbor.match(m.buf, .{ "git", tp.extract(&context), tp.more })) {
const project: *Project = @ptrFromInt(context);
project.process_git(self.parent.ref(), m) catch {};