fix: update Project.last_used when switching projects
This commit is contained in:
parent
03d07d682f
commit
7744bdf6c4
2 changed files with 6 additions and 3 deletions
|
|
@ -31,6 +31,7 @@ persistent: bool = false,
|
|||
logger: log.Logger,
|
||||
logger_lsp: log.Logger,
|
||||
logger_git: log.Logger,
|
||||
last_used: i128,
|
||||
|
||||
workspace: ?[]const u8 = null,
|
||||
|
||||
|
|
@ -100,6 +101,7 @@ pub fn init(allocator: std.mem.Allocator, name: []const u8) OutOfMemoryError!Sel
|
|||
.logger = log.logger("project"),
|
||||
.logger_lsp = log.logger("lsp"),
|
||||
.logger_git = log.logger("git"),
|
||||
.last_used = std.time.nanoTimestamp(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue