feat: query project files via git (part 1)

This commit is contained in:
CJ van den Berg 2025-04-21 21:43:29 +02:00
parent 4cb84e25b3
commit f76085325a
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
5 changed files with 75 additions and 21 deletions

View file

@ -325,6 +325,7 @@ const Process = struct {
var text_len: usize = 0;
var n: usize = 0;
var task: []const u8 = undefined;
var context: usize = undefined;
var root_dst: usize = 0;
var root_src: usize = 0;
@ -341,6 +342,9 @@ const Process = struct {
if (self.walker) |pid| pid.deinit();
self.walker = null;
self.loaded(project_directory) catch |e| return from.forward_error(e, @errorReturnTrace()) catch error.ClientFailed;
} else if (try cbor.match(m.buf, .{ "git", tp.extract(&context), tp.more })) {
const project: *Project = @ptrFromInt(context);
project.process_git(m) catch {};
} else if (try cbor.match(m.buf, .{ "update_mru", tp.extract(&project_directory), tp.extract(&path), tp.extract(&row), tp.extract(&col) })) {
self.update_mru(project_directory, path, row, col) catch |e| return from.forward_error(e, @errorReturnTrace()) catch error.ClientFailed;
} else if (try cbor.match(m.buf, .{ "child", tp.extract(&project_directory), tp.extract(&language_server), "notify", tp.extract(&method), tp.extract_cbor(&params_cb) })) {
@ -423,6 +427,7 @@ const Process = struct {
self.walker = try walk_tree_async(self.allocator, project_directory);
self.restore_project(project) catch |e| self.logger.err("restore_project", e);
project.sort_files_by_mtime();
project.query_git();
} else {
self.logger.print("switched to: {s}", .{project_directory});
}