[gnome-builder] editor: mark the first line as added when modifying a new buffer.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: mark the first line as added when modifying a new buffer.
- Date: Mon, 15 Sep 2014 08:24:22 +0000 (UTC)
commit a84f4d768aba66c6bb655d9d0ab2a6ff42bd17b4
Author: Christian Hergert <christian hergert me>
Date: Mon Sep 15 01:24:16 2014 -0700
editor: mark the first line as added when modifying a new buffer.
Just a small check to see if we added a \n from the first line so that
it gets marked as added.
src/editor/gb-source-change-monitor.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/editor/gb-source-change-monitor.c b/src/editor/gb-source-change-monitor.c
index a559ebc..e6d4273 100644
--- a/src/editor/gb-source-change-monitor.c
+++ b/src/editor/gb-source-change-monitor.c
@@ -188,8 +188,23 @@ on_insert_text_after_cb (GbSourceChangeMonitor *monitor,
if (g_strcmp0 (text, "\n") == 0)
{
+ GtkTextIter begin;
+ GtkTextIter end;
+
flags = (GB_SOURCE_CHANGE_ADDED | GB_SOURCE_CHANGE_DIRTY);
gb_source_change_monitor_insert (monitor, line, flags);
+
+ /*
+ * WORKAROUND:
+ *
+ * The following allows us to mark the first line as "added" when we
+ * edit a new buffer and type \n on the first line. Otherwise the first
+ * line shows nothing and the following lines would show "added". While
+ * technically accurate, it's not very helpful.
+ */
+ gtk_text_buffer_get_bounds (buffer, &begin, &end);
+ if (gtk_text_iter_get_line (&end) == 1)
+ gb_source_change_monitor_set_line (monitor, 0, flags);
}
else if (strchr (text, '\n') == NULL)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]