refactor(terminal): shutdown terminal on exit or project switch

This commit is contained in:
CJ van den Berg 2026-02-25 21:18:58 +01:00
parent 35ef58d0e1
commit 3ad37b3b70
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
2 changed files with 9 additions and 4 deletions

View file

@ -125,6 +125,7 @@ pub fn create(allocator: std.mem.Allocator) CreateError!Widget {
pub fn deinit(self: *Self, allocator: std.mem.Allocator) void {
self.close_all_panel_views();
terminal_view.shutdown(allocator);
self.commands.deinit();
self.widgets.deinit(allocator);
self.symbols.deinit(allocator);
@ -498,6 +499,7 @@ const cmds = struct {
{
self.closing_project = true;
defer self.closing_project = false;
terminal_view.shutdown(self.allocator);
try close_splits(self, .{});
try self.close_all_editors();
self.delete_all_buffers();

View file

@ -177,15 +177,18 @@ pub fn unfocus(self: *Self) void {
pub fn deinit(self: *Self, allocator: Allocator) void {
if (self.focused) tui.release_keyboard_focus(Widget.to(self));
// if (state) |*p| {
// p.deinit(self.allocator);
// state = null;
// }
self.commands.unregister();
self.plane.deinit();
allocator.destroy(self);
}
pub fn shutdown(allocator: Allocator) void {
if (global_vt) |*vt| {
vt.deinit(allocator);
global_vt = null;
}
}
pub fn render(self: *Self, _: *const Widget.Theme) bool {
// Drain the vt event queue.
while (self.vt.vt.tryEvent()) |event| {