From c62b27f014ddd170b8acf9293caa92effafe76ad Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 27 May 2026 20:33:03 +0100 Subject: [PATCH 1/2] Add a helper to replace a loop. --- tmux.h | 1 + window-tree.c | 18 +++--------------- window.c | 12 ++++++++++++ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/tmux.h b/tmux.h index 75a96c99..8c7e9f11 100644 --- a/tmux.h +++ b/tmux.h @@ -3430,6 +3430,7 @@ struct window *window_create(u_int, u_int, u_int, u_int); void window_pane_set_event(struct window_pane *); struct window_pane *window_get_active_at(struct window *, u_int, u_int); struct window_pane *window_find_string(struct window *, const char *); +int window_has_floating_panes(struct window *); int window_has_pane(struct window *, struct window_pane *); int window_set_active_pane(struct window *, struct window_pane *, int); diff --git a/window-tree.c b/window-tree.c index b5ba7a43..b58d0ffb 100644 --- a/window-tree.c +++ b/window-tree.c @@ -267,21 +267,9 @@ window_tree_build_window(struct session *s, struct winlink *wl, format_free(ft); if (data->type == WINDOW_TREE_SESSION || - data->type == WINDOW_TREE_WINDOW) { - expanded = 0; - /* Without this, the only way to reach a hidden - * floating pane would be to first expand the window - * manually (with the right-arrow key) and then press - * its number — which is non-obvious and breaks the - * expected workflow. - */ - TAILQ_FOREACH(fwp, &wl->window->panes, entry) { - if (fwp->flags & PANE_FLOATING) { - expanded = 1; - break; - } - } - } else + data->type == WINDOW_TREE_WINDOW) + expanded = window_has_floating_panes(wl->window); + else expanded = 1; mti = mode_tree_add(data->data, parent, item, (uint64_t)wl, name, text, expanded); diff --git a/window.c b/window.c index 3aa35f32..29ad1421 100644 --- a/window.c +++ b/window.c @@ -461,6 +461,18 @@ window_pane_send_resize(struct window_pane *wp, u_int sx, u_int sy) fatal("ioctl failed"); } +int +window_has_floating_panes(struct window *w) +{ + struct window_pane *wp; + + TAILQ_FOREACH(wp, &w->panes, entry) { + if (wp->flags & PANE_FLOATING) + return (1); + } + return (0); +} + int window_has_pane(struct window *w, struct window_pane *wp) { From bfa2ff2bdf2fb4e5da2e57003104c1a509f54af0 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 27 May 2026 20:33:41 +0100 Subject: [PATCH 2/2] Remove unused variable. --- window-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window-tree.c b/window-tree.c index b58d0ffb..49d68881 100644 --- a/window-tree.c +++ b/window-tree.c @@ -249,7 +249,7 @@ window_tree_build_window(struct session *s, struct winlink *wl, struct window_tree_itemdata *item; struct mode_tree_item *mti; char *name, *text; - struct window_pane *wp, *fwp, **l; + struct window_pane *wp, **l; u_int n, i; int expanded; struct format_tree *ft;