From 0d5067a5caf17cb375667376a4c368d444e6bf71 Mon Sep 17 00:00:00 2001 From: Cameron Dart <8763518+SkamDart@users.noreply.github.com> Date: Tue, 25 Jun 2024 11:42:27 -0700 Subject: [PATCH] gtk: noop if last active tab is closed --- src/apprt/gtk/Window.zig | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index d1b1b9f8f..ebd2efc78 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -207,6 +207,13 @@ pub fn closeTab(self: *Window, tab: *Tab) void { // Find page and tab which we're closing const page_idx = getNotebookPageIndex(page); + // If the page we are closing is the last active tab, + // then make the last active tab keybind a noop until + // a new tab is selected. + if (page_idx == self.last_active_tab_index) { + self.last_active_tab_index = -1; + } + // Remove the page. This will destroy the GTK widgets in the page which // will trigger Tab cleanup. c.gtk_notebook_remove_page(self.notebook, page_idx); @@ -297,7 +304,6 @@ pub fn gotoLastActiveTab(self: *Window) void { const page_idx = c.gtk_notebook_get_current_page(self.notebook); c.gtk_notebook_set_current_page(self.notebook, self.last_active_tab_index); self.focusCurrentTab(); - log.debug("going to last active tab", .{}); self.last_active_tab_index = page_idx; } }