=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/cmd-switch-client.c,v retrieving revision 1.37 retrieving revision 1.38 diff -c -r1.37 -r1.38 *** src/usr.bin/tmux/cmd-switch-client.c 2015/12/12 18:32:24 1.37 --- src/usr.bin/tmux/cmd-switch-client.c 2015/12/13 14:32:38 1.38 *************** *** 1,4 **** ! /* $OpenBSD: cmd-switch-client.c,v 1.37 2015/12/12 18:32:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: cmd-switch-client.c,v 1.38 2015/12/13 14:32:38 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 33,39 **** "switch-client", "switchc", "lc:Enpt:rT:", 0, 0, "[-Elnpr] [-c target-client] [-t target-session] [-T key-table]", ! CMD_READONLY, cmd_switch_client_exec }; --- 33,39 ---- "switch-client", "switchc", "lc:Enpt:rT:", 0, 0, "[-Elnpr] [-c target-client] [-t target-session] [-T key-table]", ! CMD_READONLY|CMD_CLIENT_C|CMD_PANE_T|CMD_SESSION_T|CMD_PREFERUNATTACHED, cmd_switch_client_exec }; *************** *** 41,56 **** cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; ! struct client *c; ! struct session *s = NULL; ! struct winlink *wl = NULL; ! struct window *w = NULL; ! struct window_pane *wp = NULL; ! const char *tflag, *tablename, *update; struct key_table *table; - if ((c = cmd_find_client(cmdq, args_get(args, 'c'), 0)) == NULL) - return (CMD_RETURN_ERROR); if (args_has(args, 'r')) c->flags ^= CLIENT_READONLY; --- 41,53 ---- cmd_switch_client_exec(struct cmd *self, struct cmd_q *cmdq) { struct args *args = self->args; ! struct cmd_state *state = &cmdq->state; ! struct client *c = state->c; ! struct session *s = cmdq->state.tflag.s; ! struct window_pane *wp; ! const char *tablename, *update; struct key_table *table; if (args_has(args, 'r')) c->flags ^= CLIENT_READONLY; *************** *** 68,74 **** return (CMD_RETURN_NORMAL); } - tflag = args_get(args, 't'); if (args_has(args, 'n')) { if ((s = session_next_session(c->session)) == NULL) { cmdq_error(cmdq, "can't find next session"); --- 65,70 ---- *************** *** 82,118 **** } else if (args_has(args, 'l')) { if (c->last_session != NULL && session_alive(c->last_session)) s = c->last_session; if (s == NULL) { cmdq_error(cmdq, "can't find last session"); return (CMD_RETURN_ERROR); } - } else { - if (tflag == NULL) { - if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL) - return (CMD_RETURN_ERROR); - } else if (tflag[strcspn(tflag, ":.")] != '\0') { - if ((wl = cmd_find_pane(cmdq, tflag, &s, &wp)) == NULL) - return (CMD_RETURN_ERROR); - } else { - if ((s = cmd_find_session(cmdq, tflag, 1)) == NULL) - return (CMD_RETURN_ERROR); - w = window_find_by_id_str(tflag); - if (w == NULL) { - wp = window_pane_find_by_id_str(tflag); - if (wp != NULL) - w = wp->window; - } - if (w != NULL) - wl = winlink_find_by_window(&s->windows, w); - } - if (cmdq->client == NULL) return (CMD_RETURN_NORMAL); ! if (wl != NULL) { if (wp != NULL) window_set_active_pane(wp->window, wp); ! session_set_current(s, wl); } } --- 78,98 ---- } else if (args_has(args, 'l')) { if (c->last_session != NULL && session_alive(c->last_session)) s = c->last_session; + else + s = NULL; if (s == NULL) { cmdq_error(cmdq, "can't find last session"); return (CMD_RETURN_ERROR); } if (cmdq->client == NULL) return (CMD_RETURN_NORMAL); ! s = state->tflag.s; ! if (state->tflag.wl != NULL) { ! wp = state->tflag.wp; if (wp != NULL) window_set_active_pane(wp->window, wp); ! session_set_current(s, state->tflag.wl); } }