From: Daniel Carl Date: Sat, 7 Dec 2013 14:39:22 +0000 (+0100) Subject: Moved completion flag setting to completion.c. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=aa8b30e83b20b795a837367a07913cb53fb87e3f;p=vimb.git Moved completion flag setting to completion.c. It's the better place to handle the flags than doing it in ex.c. --- diff --git a/src/completion.c b/src/completion.c index 9e697c7..f1b6dbd 100644 --- a/src/completion.c +++ b/src/completion.c @@ -139,6 +139,8 @@ gboolean completion_create(GtkTreeModel *model, CompletionSelectFunc selfunc, } #endif + vb.mode->flags |= FLAG_COMPLETION; + /* this prevents the first item to be placed out of view if the completion * is shown */ gtk_widget_show_all(comp.win); @@ -180,6 +182,7 @@ void completion_next(gboolean back) void completion_clean(void) { + vb.mode->flags &= ~FLAG_COMPLETION; if (comp.win) { gtk_widget_destroy(comp.win); comp.win = comp.tree = NULL; diff --git a/src/ex.c b/src/ex.c index f54c25f..126ae5d 100644 --- a/src/ex.c +++ b/src/ex.c @@ -197,10 +197,7 @@ void ex_enter(void) */ void ex_leave(void) { - if (vb.mode->flags & FLAG_COMPLETION) { - completion_clean(); - vb.mode->flags &= ~FLAG_COMPLETION; - } + completion_clean(); hints_clear(); } @@ -903,7 +900,6 @@ static gboolean complete(short direction) /* if direction is 0 stop the completion */ if (!direction) { completion_clean(); - vb.mode->flags &= ~FLAG_COMPLETION; return true; } @@ -922,7 +918,6 @@ static gboolean complete(short direction) /* if current input isn't the content of the completion item, stop * completion and start it after that again */ completion_clean(); - vb.mode->flags &= ~FLAG_COMPLETION; } store = gtk_list_store_new(COMPLETION_STORE_NUM, G_TYPE_STRING, G_TYPE_STRING); @@ -997,11 +992,9 @@ static gboolean complete(short direction) GTK_TREE_SORTABLE(store), COMPLETION_STORE_FIRST, GTK_SORT_ASCENDING ); } - if (found - && completion_create(GTK_TREE_MODEL(store), completion_select, direction < 0) - ) { - /* set the submode flag */ - vb.mode->flags |= FLAG_COMPLETION; + + if (found) { + completion_create(GTK_TREE_MODEL(store), completion_select, direction < 0); } g_free(input);