From 44229e8af617c80b22a7973d3aa0f454e864a9e4 Mon Sep 17 00:00:00 2001 From: Michael Grant Date: Sat, 28 Mar 2026 08:35:35 +0000 Subject: [PATCH] Fix a crash when clicking a floating pane in the status line which was minimised after it was made active by window-tree. Correct the way window-tree displays floating panes so they can be easily unminimmised. --- layout.c | 2 ++ window-tree.c | 18 +++++++++++++++--- window.c | 7 +++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/layout.c b/layout.c index 3bc9609d..788497db 100644 --- a/layout.c +++ b/layout.c @@ -628,6 +628,8 @@ layout_unminimise_cell(struct window *w, struct layout_cell *lc) { struct layout_cell *lcother, *lcparent; + if (lc == NULL) + return; lcparent = lc->parent; if (lcparent == NULL) { return; diff --git a/window-tree.c b/window-tree.c index 9d2f8575..ed3c9d69 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, **l; + struct window_pane *wp, *fwp, **l; u_int n, i; int expanded; struct format_tree *ft; @@ -267,9 +267,21 @@ window_tree_build_window(struct session *s, struct winlink *wl, format_free(ft); if (data->type == WINDOW_TREE_SESSION || - data->type == WINDOW_TREE_WINDOW) + data->type == WINDOW_TREE_WINDOW) { expanded = 0; - else + /* Without this, the only way to reach a minimised + * 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 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 2f61eb14..0ec69372 100644 --- a/window.c +++ b/window.c @@ -541,7 +541,7 @@ window_set_active_pane(struct window *w, struct window_pane *wp, int notify) if (wp->flags & PANE_MINIMISED) { wp->flags &= ~PANE_MINIMISED; - if (w->layout_root != NULL) { + if (w->layout_root != NULL && wp->saved_layout_cell != NULL) { wp->layout_cell = wp->saved_layout_cell; wp->saved_layout_cell = NULL; layout_unminimise_cell(w, wp->layout_cell); @@ -791,7 +791,10 @@ window_unzoom(struct window *w, int notify) TAILQ_FOREACH(wp, &w->panes, entry) { wp->layout_cell = wp->saved_layout_cell; - wp->saved_layout_cell = NULL; + if (wp->flags & PANE_MINIMISED) + wp->saved_layout_cell = wp->layout_cell; + else + wp->saved_layout_cell = NULL; wp->flags &= ~PANE_ZOOMED; } layout_fix_panes(w, NULL);