[gnome-builder] libide: synthesize line additions for new files in the workdir



commit 05f93aa47caaeae14ff56f0b7c5678e9158249dc
Author: Christian Hergert <christian hergert me>
Date:   Thu Feb 26 17:57:23 2015 -0800

    libide: synthesize line additions for new files in the workdir
    
    If the file is a descendant of the Git repositories working directory,
    then we will synthesize every line as a IDE_BUFFER_LINE_CHANGE_ADDED.

 libide/git/ide-git-buffer-change-monitor.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/libide/git/ide-git-buffer-change-monitor.c b/libide/git/ide-git-buffer-change-monitor.c
index 7d31e67..700fbe0 100644
--- a/libide/git/ide-git-buffer-change-monitor.c
+++ b/libide/git/ide-git-buffer-change-monitor.c
@@ -54,6 +54,7 @@ struct _IdeGitBufferChangeMonitor
   guint           state_dirty : 1;
   guint           in_calculation : 1;
   guint           delete_range_requires_recalculation : 1;
+  guint           is_child_of_workdir : 1;
 };
 
 typedef struct
@@ -63,6 +64,7 @@ typedef struct
   GFile          *file;
   GBytes         *content;
   GgitBlob       *blob;
+  guint           is_child_of_workdir : 1;
 } DiffTask;
 
 G_DEFINE_TYPE (IdeGitBufferChangeMonitor,
@@ -111,6 +113,9 @@ ide_git_buffer_change_monitor_calculate_finish (IdeGitBufferChangeMonitor  *self
   if (diff->blob != self->cached_blob)
     g_set_object (&self->cached_blob, diff->blob);
 
+  /* If the file is a child of the working directory, we need to know */
+  self->is_child_of_workdir = diff->is_child_of_workdir;
+
   return g_task_propagate_pointer (task, error);
 }
 
@@ -172,7 +177,14 @@ ide_git_buffer_change_monitor_get_change (IdeBufferChangeMonitor *monitor,
   g_return_val_if_fail (iter, IDE_BUFFER_LINE_CHANGE_NONE);
 
   if (!self->state)
-    return IDE_BUFFER_LINE_CHANGE_NONE;
+    {
+      /*
+       * If the file is within the working directory, synthesize line addition.
+       */
+      if (self->is_child_of_workdir)
+        return IDE_BUFFER_LINE_CHANGE_ADDED;
+      return IDE_BUFFER_LINE_CHANGE_NONE;
+    }
 
   key = GINT_TO_POINTER (gtk_text_iter_get_line (iter) + 1);
   value = g_hash_table_lookup (self->state, key);
@@ -516,6 +528,8 @@ ide_git_buffer_change_monitor_calculate_threaded (IdeGitBufferChangeMonitor  *se
       return FALSE;
     }
 
+  diff->is_child_of_workdir = TRUE;
+
   /*
    * Find the blob if necessary. This will be cached by the main thread for us on the way out
    * of the async operation.


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