[gnome-builder] git: improve line marks
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] git: improve line marks
- Date: Sat, 3 Feb 2018 10:23:42 +0000 (UTC)
commit aff05372163eb371e8878d24347deb7b91218f6f
Author: Christian Hergert <chergert redhat com>
Date: Sat Feb 3 01:57:59 2018 -0800
git: improve line marks
These turn out to be quite tricky to get right. But anyway, this appears
to be better. Left some comments for the next person to take a look.
src/plugins/git/ide-git-buffer-change-monitor.c | 46 +++++++++++++++++++++----
1 file changed, 40 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/git/ide-git-buffer-change-monitor.c b/src/plugins/git/ide-git-buffer-change-monitor.c
index dffe51463..657d2b88a 100644
--- a/src/plugins/git/ide-git-buffer-change-monitor.c
+++ b/src/plugins/git/ide-git-buffer-change-monitor.c
@@ -81,7 +81,8 @@ typedef struct
typedef struct
{
gint line;
- IdeBufferLineChange change;
+ IdeBufferLineChange change : 3;
+ guint really_delete : 1;
} DiffLine;
typedef struct
@@ -564,15 +565,48 @@ diff_line_cb (GgitDiffDelta *delta,
new_lineno = ggit_diff_line_get_new_lineno (line);
old_lineno = ggit_diff_line_get_old_lineno (line);
+ /*
+ * The callbacks here are are somewhat cryptic and have been little
+ * tweak, one after another.
+ *
+ * What I glean, thus far, is that things happen like this (after
+ * we've accouned for the line number drift). If something looks off,
+ * it probably is!
+ *
+ * Scenario 1
+ * - Delete N
+ * - Delete N
+ * - Added N
+ * This means that N is both a change and the previous line(s)
+ * where deleted.
+ *
+ * Scenario 2
+ * - Delete N
+ * This means the line(s) previous to N were deleted.
+ *
+ * Scenario 3
+ * - Delete N
+ * - Added N
+ * This means N was changed.
+ *
+ * Scenario 4
+ *
+ * - Added N
+ * This means N was added.
+ */
+
switch (type)
{
case GGIT_DIFF_LINE_ADDITION:
diff_line = find_or_add_line (info->lines, new_lineno);
- if (diff_line->change != 0)
- diff_line->change |= IDE_BUFFER_LINE_CHANGE_CHANGED;
+ if (diff_line->change == IDE_BUFFER_LINE_CHANGE_DELETED)
+ diff_line->change = IDE_BUFFER_LINE_CHANGE_CHANGED;
else
diff_line->change = IDE_BUFFER_LINE_CHANGE_ADDED;
+ if (diff_line->really_delete)
+ diff_line->change |= IDE_BUFFER_LINE_CHANGE_DELETED;
+
info->hunk_add_count++;
break;
@@ -585,9 +619,9 @@ diff_line_cb (GgitDiffDelta *delta,
old_lineno += info->hunk_add_count - info->hunk_del_count;
diff_line = find_or_add_line (info->lines, old_lineno);
- if (diff_line->change != 0)
- diff_line->change |= IDE_BUFFER_LINE_CHANGE_CHANGED;
- diff_line->change |= IDE_BUFFER_LINE_CHANGE_DELETED;
+ if (diff_line->change & IDE_BUFFER_LINE_CHANGE_DELETED)
+ diff_line->really_delete = TRUE;
+ diff_line->change = IDE_BUFFER_LINE_CHANGE_DELETED;
info->hunk_del_count++;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]