diff --git a/src/tui/mainview.zig b/src/tui/mainview.zig index 91772e4..e3463aa 100644 --- a/src/tui/mainview.zig +++ b/src/tui/mainview.zig @@ -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(); diff --git a/src/tui/terminal_view.zig b/src/tui/terminal_view.zig index 389751a..89c6a2f 100644 --- a/src/tui/terminal_view.zig +++ b/src/tui/terminal_view.zig @@ -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| {