summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-09-21 18:16:31 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-09-21 18:16:31 +0000
commitd63977ea8a9bd3109eea77535cea2536c3f73b67 (patch)
tree88bf918683b2030c82d3339b1b9feca64e549a48
parent1702a781bb4e31e44c9eb21503c5812d5a058d06 (diff)
session_last == -1 could still leave us with the window we are about to remove.
-rw-r--r--session.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/session.c b/session.c
index 6d8165ab..432756fe 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
-/* $Id: session.c,v 1.9 2007-09-20 18:03:23 nicm Exp $ */
+/* $Id: session.c,v 1.10 2007-09-21 18:16:31 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -129,11 +129,11 @@ session_attach(struct session *s, struct window *w)
int
session_detach(struct session *s, struct window *w)
{
- if (s->window == w) {
- if (session_last(s) == -1)
- session_previous(s);
- }
+ /* Move to last, previous of next window if possible. */
+ if (s->window == w && session_last(s) != 0 && session_previous(s) != 0)
+ session_next(s);
+ /* Remove the window from the list. */
window_remove(&s->windows, w);
/* Destroy session if it is empty. */