summaryrefslogtreecommitdiffstats
path: root/session.c
diff options
context:
space:
mode:
authornicm <nicm>2022-10-17 10:59:42 +0000
committernicm <nicm>2022-10-17 10:59:42 +0000
commitff2766b024e6657b5f5f70dfd5acdb32085d7b70 (patch)
tree50b255efd85076d2724e1a4014d010155bf0d0a6 /session.c
parenta10452be2d84d4ff1b9d4e636627b7a9c5a2c42a (diff)
Preserve marked pane when renumbering windows.
Diffstat (limited to 'session.c')
-rw-r--r--session.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/session.c b/session.c
index 5bc5330e..c9a98d23 100644
--- a/session.c
+++ b/session.c
@@ -710,7 +710,7 @@ session_renumber_windows(struct session *s)
struct winlink *wl, *wl1, *wl_new;
struct winlinks old_wins;
struct winlink_stack old_lastw;
- int new_idx, new_curw_idx;
+ int new_idx, new_curw_idx, marked_idx = -1;
/* Save and replace old window list. */
memcpy(&old_wins, &s->windows, sizeof old_wins);
@@ -727,6 +727,8 @@ session_renumber_windows(struct session *s)
winlink_set_window(wl_new, wl->window);
wl_new->flags |= wl->flags & WINLINK_ALERTFLAGS;
+ if (wl == marked_pane.wl)
+ marked_idx = wl_new->idx;
if (wl == s->curw)
new_curw_idx = wl_new->idx;
@@ -743,6 +745,11 @@ session_renumber_windows(struct session *s)
}
/* Set the current window. */
+ if (marked_idx != -1) {
+ marked_pane.wl = winlink_find_by_index(&s->windows, marked_idx);
+ if (marked_pane.wl == NULL)
+ server_clear_marked();
+ }
s->curw = winlink_find_by_index(&s->windows, new_curw_idx);
/* Free the old winlinks (reducing window references too). */