summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/cmds.c5
-rw-r--r--src/main/completion.c14
-rw-r--r--src/main/main.c5
3 files changed, 22 insertions, 2 deletions
diff --git a/src/main/cmds.c b/src/main/cmds.c
index 989f28e..a7b509d 100644
--- a/src/main/cmds.c
+++ b/src/main/cmds.c
@@ -334,7 +334,10 @@ int32_t buflist_refresh_cmd(struct command_ctx ctx, int argc,
const char *argv[]) {
(void)argc;
(void)argv;
- buflist_refresh(window_buffer(ctx.active_window), ctx.buffers);
+ struct buffer *b = buffers_find(ctx.buffers, "*buffers*");
+ if (b != NULL) {
+ buflist_refresh(b, ctx.buffers);
+ }
return 0;
}
diff --git a/src/main/completion.c b/src/main/completion.c
index 7c5de47..23b3a58 100644
--- a/src/main/completion.c
+++ b/src/main/completion.c
@@ -140,7 +140,10 @@ COMMAND_FN("prev-completion", prev_completion, goto_prev_completion, NULL)
COMMAND_FN("insert-completion", insert_completion, insert_completion, NULL)
static void clear_completions(struct completion_state *state) {
- buffer_clear(state->completions_buffer);
+ if (g_state.completions_buffer != NULL) {
+ buffer_clear(state->completions_buffer);
+ }
+
VEC_FOR_EACH(&state->completions, struct completion_item * item) {
if (item->completion.cleanup != NULL) {
item->completion.cleanup(item->completion.data);
@@ -326,6 +329,12 @@ static void on_buffer_delete(struct buffer *buffer, struct edit_location edit,
on_buffer_changed(buffer, edit, true, userdata);
}
+static void completions_buffer_deleted(struct buffer *buffer, void *userdata) {
+ (void)buffer;
+ struct completion_state *state = (struct completion_state *)userdata;
+ state->completions_buffer = NULL;
+}
+
void init_completion(struct buffers *buffers) {
if (g_state.completions_buffer == NULL) {
struct buffer b = buffer_create("*completions*");
@@ -340,6 +349,9 @@ void init_completion(struct buffers *buffers) {
buffer_add_update_hook(g_state.completions_buffer, update_comp_buffer,
&g_state);
+ buffer_add_destroy_hook(g_state.completions_buffer,
+ completions_buffer_deleted, &g_state);
+
g_state.keymap_id = (uint64_t)-1;
g_state.target = NULL;
diff --git a/src/main/main.c b/src/main/main.c
index 2e2df58..70c62a3 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -391,6 +391,11 @@ int main(int argc, char *argv[]) {
needs_render = true;
}
+ if (buffers_num_buffers(&buflist) == 0) {
+ running = false;
+ continue;
+ }
+
// TODO: maybe this should be hidden behind something
// The placement is correct though.
buffers_for_each(&buflist, clear_buffer_props, NULL);