[gnome-builder] git: use ADDED change for new files, otherwise NONE
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] git: use ADDED change for new files, otherwise NONE
- Date: Mon, 22 Apr 2019 23:04:05 +0000 (UTC)
commit eb41536ccd7f6f2e77b4d2f36bf05a2d075e4968
Author: Christian Hergert <chergert redhat com>
Date: Mon Apr 22 16:03:34 2019 -0700
git: use ADDED change for new files, otherwise NONE
This ensures we preserve the current state of "don't show line adds"
before we know file state (to avoid flicker), but still set added for
new files which is needed to ensure we trim lines.
src/plugins/git/gbp-git-buffer-change-monitor.c | 34 +++++++++++++++++--------
1 file changed, 23 insertions(+), 11 deletions(-)
---
diff --git a/src/plugins/git/gbp-git-buffer-change-monitor.c b/src/plugins/git/gbp-git-buffer-change-monitor.c
index 2f41fdf86..b7abb775d 100644
--- a/src/plugins/git/gbp-git-buffer-change-monitor.c
+++ b/src/plugins/git/gbp-git-buffer-change-monitor.c
@@ -39,6 +39,7 @@ struct _GbpGitBufferChangeMonitor
guint last_change_count;
guint queued_source;
guint delete_range_requires_recalculation : 1;
+ guint not_found : 1;
};
enum { SLOW, FAST };
@@ -285,8 +286,16 @@ gbp_git_buffer_change_monitor_foreach_change (IdeBufferChangeMonitor
if (self->cache == NULL)
{
+ guint change;
+
+ if (self->not_found)
+ change = IDE_BUFFER_LINE_CHANGE_ADDED;
+ else
+ change = IDE_BUFFER_LINE_CHANGE_NONE;
+
for (guint i = begin_line; i < end_line; i++)
- callback (i, IDE_BUFFER_LINE_CHANGE_NONE, user_data);
+ callback (i, change, user_data);
+
return;
}
@@ -433,23 +442,26 @@ gbp_git_buffer_change_monitor_wait_cb (GObject *object,
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (IDE_IS_TASK (task));
+ self = ide_task_get_source_object (task);
+
if (!ipc_git_change_monitor_call_list_changes_finish (proxy, &changes, result, &error))
{
- ide_task_return_error (task, g_steal_pointer (&error));
- return;
- }
-
- self = ide_task_get_source_object (task);
+ g_clear_pointer (&self->cache, line_cache_free);
+ self->not_found = TRUE;
- if (changes != NULL)
+ if (g_error_matches (error, G_DBUS_ERROR, G_DBUS_ERROR_FILE_NOT_FOUND))
+ ide_task_return_boolean (task, TRUE);
+ else
+ ide_task_return_error (task, g_steal_pointer (&error));
+ }
+ else
{
g_clear_pointer (&self->cache, line_cache_free);
+ self->not_found = FALSE;
self->cache = line_cache_new_from_variant (changes);
+ ide_buffer_change_monitor_emit_changed (IDE_BUFFER_CHANGE_MONITOR (self));
+ ide_task_return_boolean (task, TRUE);
}
-
- ide_buffer_change_monitor_emit_changed (IDE_BUFFER_CHANGE_MONITOR (self));
-
- ide_task_return_boolean (task, TRUE);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]