Keep focus on a visible pane when panes are shown, spawned or closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Michael Grant
2026-10-01 11:14:28 +01:00
parent e0815b51f6
commit c50d075122
2 changed files with 16 additions and 5 deletions

10
spawn.c
View File

@@ -254,7 +254,7 @@ spawn_pane(struct spawn_context *sc, char **cause)
char path[PATH_MAX];
const char *cmd, *tmp, *home = find_home();
const char *actual_cwd = NULL;
int argc;
int argc, detached;
u_int idx;
struct termios now;
u_int hlimit;
@@ -588,6 +588,11 @@ complete:
return (new_wp);
if (sc->flags & SPAWN_ZOOM)
window_zoom(new_wp);
/* Make the pane active, even if detached, if keys would go nowhere. */
detached = (sc->flags & SPAWN_DETACHED);
if (w->active == NULL || (w->active->flags & PANE_HIDDEN))
detached = 0;
if (sc->flags & SPAWN_MODAL) {
w->modal_last = w->active;
w->modal = new_wp;
@@ -596,8 +601,7 @@ complete:
window_set_active_pane(w, new_wp, 0);
else
window_set_active_pane(w, new_wp, 1);
} else if (((~sc->flags & SPAWN_DETACHED) || w->active == NULL) &&
w->modal == NULL) {
} else if (!detached && w->modal == NULL) {
if (sc->flags & SPAWN_NONOTIFY)
window_set_active_pane(w, new_wp, 0);
else