[gnome-builder] smart-backspace: ignore lines that are not empty before the cursor



commit 0ec7dd951647008b0bbdfbfbb1ebbcf9c86eae14
Author: Christian Hergert <christian hergert me>
Date:   Fri Mar 27 17:35:44 2015 -0700

    smart-backspace: ignore lines that are not empty before the cursor
    
    This fixes multiple backspaces when it's really not expected (such as
    inside of multiline comments with prefixed *).

 libide/ide-source-view.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-view.c b/libide/ide-source-view.c
index ecdfc46..8dd078d 100644
--- a/libide/ide-source-view.c
+++ b/libide/ide-source-view.c
@@ -2045,6 +2045,7 @@ ide_source_view_do_smart_backspace (IdeSourceView *self,
   GtkTextBuffer *buffer;
   GtkTextIter insert;
   GtkTextIter end;
+  GtkTextIter tmp;
   guint visual_column;
   gint indent_width;
   gint tab_width;
@@ -2062,6 +2063,15 @@ ide_source_view_do_smart_backspace (IdeSourceView *self,
   if (!gtk_text_iter_equal (&insert, &end))
     return FALSE;
 
+  /* if the line isn't empty up to our cursor, ignore */
+  tmp = insert;
+  while (!gtk_text_iter_starts_line (&tmp))
+    {
+      if (!g_unichar_isspace (gtk_text_iter_get_char (&tmp)))
+        return FALSE;
+      gtk_text_iter_backward_char (&tmp);
+    }
+
   visual_column = GET_VISUAL_COLUMN (&insert);
   indent_width = gtk_source_view_get_indent_width (GTK_SOURCE_VIEW (self));
   tab_width = gtk_source_view_get_tab_width (GTK_SOURCE_VIEW (self));


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