gtk: make goto_tab go to last tab if too large

This commit is contained in:
Mitchell Hashimoto
2024-10-24 20:01:07 -07:00
parent a651dbf3bf
commit a793ad2f0d

View File

@ -466,11 +466,10 @@ pub fn gotoLastTab(self: *Window) void {
pub fn gotoTab(self: *Window, n: usize) void {
if (n == 0) return;
const max = self.notebook.nPages();
if (max == 0) return;
const page_idx = std.math.cast(c_int, n - 1) orelse return;
if (page_idx < max) {
self.notebook.gotoNthTab(page_idx);
self.notebook.gotoNthTab(@min(page_idx, max - 1));
self.focusCurrentTab();
}
}
/// Toggle tab overview (if present)