=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/window.c,v retrieving revision 1.265 retrieving revision 1.266 diff -u -r1.265 -r1.266 --- src/usr.bin/tmux/window.c 2020/06/05 11:20:51 1.265 +++ src/usr.bin/tmux/window.c 2020/06/13 09:05:53 1.266 @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.265 2020/06/05 11:20:51 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.266 2020/06/13 09:05:53 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -1490,13 +1490,16 @@ /* Shuffle window indexes up. */ int -winlink_shuffle_up(struct session *s, struct winlink *wl) +winlink_shuffle_up(struct session *s, struct winlink *wl, int before) { int idx, last; if (wl == NULL) return (-1); - idx = wl->idx + 1; + if (before) + idx = wl->idx; + else + idx = wl->idx + 1; /* Find the next free index. */ for (last = idx; last < INT_MAX; last++) { @@ -1509,8 +1512,9 @@ /* Move everything from last - 1 to idx up a bit. */ for (; last > idx; last--) { wl = winlink_find_by_index(&s->windows, last - 1); - server_link_window(s, wl, s, last, 0, 0, NULL); - server_unlink_window(s, wl); + RB_REMOVE(winlinks, &s->windows, wl); + wl->idx++; + RB_INSERT(winlinks, &s->windows, wl); } return (idx);