=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/session.c,v retrieving revision 1.36 retrieving revision 1.37 diff -c -r1.36 -r1.37 *** src/usr.bin/tmux/session.c 2012/07/10 11:53:01 1.36 --- src/usr.bin/tmux/session.c 2013/03/22 16:00:26 1.37 *************** *** 1,4 **** ! /* $OpenBSD: session.c,v 1.36 2012/07/10 11:53:01 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: session.c,v 1.37 2013/03/22 16:00:26 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 346,358 **** if (alert && ((wl = session_next_alert(wl)) == NULL)) return (-1); } ! if (wl == s->curw) ! return (1); ! winlink_stack_remove(&s->lastw, wl); ! winlink_stack_push(&s->lastw, s->curw); ! s->curw = wl; ! winlink_clear_flags(wl); ! return (0); } struct winlink * --- 346,352 ---- if (alert && ((wl = session_next_alert(wl)) == NULL)) return (-1); } ! return (session_set_current(s, wl)); } struct winlink * *************** *** 383,395 **** if (alert && (wl = session_previous_alert(wl)) == NULL) return (-1); } ! if (wl == s->curw) ! return (1); ! winlink_stack_remove(&s->lastw, wl); ! winlink_stack_push(&s->lastw, s->curw); ! s->curw = wl; ! winlink_clear_flags(wl); ! return (0); } /* Move session to specific window. */ --- 377,383 ---- if (alert && (wl = session_previous_alert(wl)) == NULL) return (-1); } ! return (session_set_current(s, wl)); } /* Move session to specific window. */ *************** *** 399,413 **** struct winlink *wl; wl = winlink_find_by_index(&s->windows, idx); ! if (wl == NULL) ! return (-1); ! if (wl == s->curw) ! return (1); ! winlink_stack_remove(&s->lastw, wl); ! winlink_stack_push(&s->lastw, s->curw); ! s->curw = wl; ! winlink_clear_flags(wl); ! return (0); } /* Move session to last used window. */ --- 387,393 ---- struct winlink *wl; wl = winlink_find_by_index(&s->windows, idx); ! return (session_set_current(s, wl)); } /* Move session to last used window. */ *************** *** 417,422 **** --- 397,414 ---- struct winlink *wl; wl = TAILQ_FIRST(&s->lastw); + if (wl == NULL) + return (-1); + if (wl == s->curw) + return (1); + + return (session_set_current(s, wl)); + } + + /* Set current winlink to wl .*/ + int + session_set_current(struct session *s, struct winlink *wl) + { if (wl == NULL) return (-1); if (wl == s->curw)