[gnome-builder] editor: special case \n insertion for change tracking.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] editor: special case \n insertion for change tracking.
- Date: Mon, 15 Sep 2014 22:05:25 +0000 (UTC)
commit ba93cccd54fff8a22f5ef552d69bcbf1055a8c3a
Author: Christian Hergert <christian hergert me>
Date: Mon Sep 15 15:05:19 2014 -0700
editor: special case \n insertion for change tracking.
Now when you \n at the beginning of the line, we track the insert on the
correct line.
src/editor/gb-source-change-monitor.c | 17 ++++++++++++++++-
1 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/src/editor/gb-source-change-monitor.c b/src/editor/gb-source-change-monitor.c
index dc43d49..0a595fe 100644
--- a/src/editor/gb-source-change-monitor.c
+++ b/src/editor/gb-source-change-monitor.c
@@ -32,6 +32,9 @@ struct _GbSourceChangeMonitorPrivate
guint delete_range_after_handler;
guint insert_text_before_handler;
guint insert_text_after_handler;
+
+ guint insert_begin_line;
+ guint insert_begin_offset;
};
enum
@@ -249,12 +252,18 @@ on_insert_text_before_cb (GbSourceChangeMonitor *monitor,
gint len,
GtkTextBuffer *buffer)
{
+ GbSourceChangeMonitorPrivate *priv;
GtkTextIter begin;
GtkTextIter end;
g_return_if_fail (GB_IS_SOURCE_CHANGE_MONITOR (monitor));
g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
+ priv = monitor->priv;
+
+ priv->insert_begin_line = gtk_text_iter_get_line (location);
+ priv->insert_begin_offset = gtk_text_iter_get_line_offset (location);
+
gtk_text_buffer_get_bounds (buffer, &begin, &end);
/*
@@ -277,18 +286,24 @@ on_insert_text_after_cb (GbSourceChangeMonitor *monitor,
gint len,
GtkTextBuffer *buffer)
{
+ GbSourceChangeMonitorPrivate *priv;
GbSourceChangeFlags flags = 0;
guint line;
g_return_if_fail (GB_IS_SOURCE_CHANGE_MONITOR (monitor));
g_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
+ priv = monitor->priv;
+
line = gtk_text_iter_get_line (location);
if (g_strcmp0 (text, "\n") == 0)
{
flags = (GB_SOURCE_CHANGE_ADDED | GB_SOURCE_CHANGE_DIRTY);
- gb_source_change_monitor_insert (monitor, line, flags);
+ if (priv->insert_begin_offset == 0)
+ gb_source_change_monitor_insert (monitor, line-1, flags);
+ else
+ gb_source_change_monitor_insert (monitor, line, flags);
}
else if (strchr (text, '\n') == NULL)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]