Moved completion flag setting to completion.c.
authorDaniel Carl <danielcarl@gmx.de>
Sat, 7 Dec 2013 14:39:22 +0000 (15:39 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Sat, 7 Dec 2013 14:39:22 +0000 (15:39 +0100)
It's the better place to handle the flags than doing it in ex.c.

src/completion.c
src/ex.c

index 9e697c7..f1b6dbd 100644 (file)
@@ -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;
index f54c25f..126ae5d 100644 (file)
--- 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);