summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--degesch.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/degesch.c b/degesch.c
index e0c75ab..929e43c 100644
--- a/degesch.c
+++ b/degesch.c
@@ -3130,6 +3130,16 @@ buffer_get_index (struct app_context *ctx, struct buffer *buffer)
}
static void
+buffer_remove_safe (struct app_context *ctx, struct buffer *buffer)
+{
+ if (buffer == ctx->current_buffer)
+ buffer_activate (ctx, ctx->last_buffer
+ ? ctx->last_buffer
+ : buffer_next (ctx, 1));
+ buffer_remove (ctx, buffer);
+}
+
+static void
init_global_buffer (struct app_context *ctx)
{
struct buffer *global = ctx->global_buffer = buffer_new ();
@@ -6718,12 +6728,7 @@ handle_buffer_close (struct app_context *ctx, struct handler_args *a)
// The user would be unable to recreate the buffer otherwise
if (buffer->type == BUFFER_CHANNEL)
part_channel (buffer->server, buffer->channel->name, "");
-
- if (buffer == ctx->current_buffer)
- buffer_activate (ctx, ctx->last_buffer
- ? ctx->last_buffer
- : buffer_next (ctx, 1));
- buffer_remove (ctx, buffer);
+ buffer_remove_safe (ctx, buffer);
}
}