fix: update Project.last_used when switching projects

This commit is contained in:
CJ van den Berg 2025-11-05 16:33:12 +01:00
parent 03d07d682f
commit 7744bdf6c4
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 6 additions and 3 deletions

View file

@ -463,15 +463,16 @@ const Process = struct {
}
fn open(self: *Process, project_directory: []const u8) (SpawnError || std.fs.Dir.OpenError)!void {
if (self.projects.get(project_directory) == null) {
if (self.projects.get(project_directory)) |project| {
project.last_used = std.time.nanoTimestamp();
self.logger.print("switched to: {s}", .{project_directory});
} else {
self.logger.print("opening: {s}", .{project_directory});
const project = try self.allocator.create(Project);
project.* = try Project.init(self.allocator, project_directory);
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();
} else {
self.logger.print("switched to: {s}", .{project_directory});
}
}