[gnome-builder] ctags: avoid ctags indexing until a file has been saved



commit b204b18fe1e3de061e0eb358b855819348d52e6f
Author: Christian Hergert <chergert redhat com>
Date:   Mon Feb 4 20:42:14 2019 -0800

    ctags: avoid ctags indexing until a file has been saved
    
    This delays all ctags indexing work until the user opens and saves a file.
    It's not the best heuristic, but it's better than scanning everytime the
    project is opened, which tends to annoy users.

 src/plugins/ctags/ide-ctags-service.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/plugins/ctags/ide-ctags-service.c b/src/plugins/ctags/ide-ctags-service.c
index bbcc07e37..d1281553b 100644
--- a/src/plugins/ctags/ide-ctags-service.c
+++ b/src/plugins/ctags/ide-ctags-service.c
@@ -48,6 +48,7 @@ struct _IdeCtagsService
   IdeNotification  *notif;
   gint              n_active;
 
+  guint             did_full_build : 1;
   guint             queued_miner_handler;
   guint             miner_active : 1;
   guint             paused : 1;
@@ -672,6 +673,13 @@ ide_ctags_service_buffer_saved (IdeCtagsService  *self,
   context = ide_object_get_context (IDE_OBJECT (self));
   workdir = ide_context_ref_workdir (context);
 
+  if (!self->did_full_build)
+    {
+      self->did_full_build = TRUE;
+      ide_ctags_service_queue_build_for_directory (self, workdir, TRUE);
+      return;
+    }
+
   file = ide_buffer_get_file (buffer);
   parent = g_file_get_parent (file);
 
@@ -707,11 +715,10 @@ ide_ctags_service_parent_set (IdeObject *object,
                            self,
                            G_CONNECT_SWAPPED);
 
-  /*
-   * Rebuild all ctags for the project at startup of the service.
-   * Then we do incrementals from there on out.
+  /* We don't do any rebuilds up-front because users find them annoying.
+   * Instead, we wait until a file has been saved and then re-index content
+   * for the whole project (if necessary).
    */
-  ide_ctags_service_queue_build_for_directory (self, workdir, TRUE);
 
   IDE_EXIT;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]