summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd-new-session.c17
-rw-r--r--cmd-switch-client.c7
-rw-r--r--server-client.c2
-rw-r--r--server-fn.c2
-rw-r--r--tmux.h2
5 files changed, 14 insertions, 16 deletions
diff --git a/cmd-new-session.c b/cmd-new-session.c
index 573b0ebb..5511da5d 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -122,7 +122,7 @@ int
cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_new_session_data *data = self->data;
- struct session *s, *groupwith;
+ struct session *s, *old_s, *groupwith;
struct window *w;
struct window_pane *wp;
struct environ env;
@@ -279,17 +279,16 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if (!detached) {
if (ctx->cmdclient != NULL) {
server_write_client(ctx->cmdclient, MSG_READY, NULL, 0);
- if (ctx->cmdclient->session != NULL) {
- session_index(ctx->cmdclient->session,
- &ctx->cmdclient->last_session);
- }
+
+ old_s = ctx->cmdclient->session;
+ if (old_s != NULL)
+ ctx->cmdclient->last_session = old_s;
ctx->cmdclient->session = s;
server_redraw_client(ctx->cmdclient);
} else {
- if (ctx->curclient->session != NULL) {
- session_index(ctx->curclient->session,
- &ctx->curclient->last_session);
- }
+ old_s = ctx->curclient->session;
+ if (old_s != NULL)
+ ctx->curclient->last_session = old_s;
ctx->curclient->session = s;
server_redraw_client(ctx->curclient);
}
diff --git a/cmd-switch-client.c b/cmd-switch-client.c
index dfe8aca1..1be8a6c7 100644
--- a/cmd-switch-client.c
+++ b/cmd-switch-client.c
@@ -159,9 +159,8 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
}
} else if (data->flag_last) {
- if (c->last_session != UINT_MAX &&
- c->last_session < ARRAY_LENGTH(&sessions))
- s = ARRAY_ITEM(&sessions, c->last_session);
+ if (c->last_session != NULL && session_alive(c->last_session))
+ s = c->last_session;
if (s == NULL) {
ctx->error(ctx, "can't find last session");
return (-1);
@@ -172,7 +171,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
return (-1);
if (c->session != NULL)
- session_index(c->session, &c->last_session);
+ c->last_session = c->session;
c->session = s;
recalculate_sizes();
diff --git a/server-client.c b/server-client.c
index 290a175a..c4cc9847 100644
--- a/server-client.c
+++ b/server-client.c
@@ -78,7 +78,7 @@ server_client_create(int fd)
c->title = NULL;
c->session = NULL;
- c->last_session = UINT_MAX;
+ c->last_session = NULL;
c->tty.sx = 80;
c->tty.sy = 24;
diff --git a/server-fn.c b/server-fn.c
index 20a245e0..134cfb6e 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -399,7 +399,7 @@ server_destroy_session(struct session *s)
c->session = NULL;
c->flags |= CLIENT_EXIT;
} else {
- c->last_session = UINT_MAX;
+ c->last_session = NULL;
c->session = s_new;
server_redraw_client(c);
}
diff --git a/tmux.h b/tmux.h
index 0f36c92e..8b384af1 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1155,7 +1155,7 @@ struct client {
struct mode_key_data prompt_mdata;
struct session *session;
- u_int last_session;
+ struct session *last_session;
int references;
};