Fix save file initialisation & incorrect saved session index

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2025-12-05 19:49:27 +01:00
parent 7e18d906c4
commit 92beb24c80
2 changed files with 12 additions and 7 deletions

View File

@@ -17,10 +17,12 @@ const EnvironmentLabel = generic.CyclableLabel(Env, *UserList);
const Session = @This();
label: EnvironmentLabel,
user_list: *UserList,
pub fn init(allocator: Allocator, buffer: *TerminalBuffer, user_list: *UserList) Session {
return .{
.label = EnvironmentLabel.init(allocator, buffer, drawItem, sessionChanged, user_list),
.user_list = user_list,
};
}
@@ -36,7 +38,10 @@ pub fn deinit(self: *Session) void {
}
pub fn addEnvironment(self: *Session, environment: Environment) !void {
try self.label.addItem(.{ .environment = environment, .index = self.label.list.items.len });
const env = Env{ .environment = environment, .index = self.label.list.items.len };
try self.label.addItem(env);
sessionChanged(env, self.user_list);
}
fn sessionChanged(env: Env, maybe_user_list: ?*UserList) void {