[gtksourceview/gtksourceview-4-8] view: fix decrement of negative numbers



commit e3ab9835e54f9272a326f53c1b1ebc64d83b1b6b
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jul 28 17:49:40 2021 -0700

    view: fix decrement of negative numbers
    
    Fixes #117

 gtksourceview/gtksourceview.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
---
diff --git a/gtksourceview/gtksourceview.c b/gtksourceview/gtksourceview.c
index 5db18ea7..1b87975a 100644
--- a/gtksourceview/gtksourceview.c
+++ b/gtksourceview/gtksourceview.c
@@ -387,7 +387,18 @@ gtk_source_view_change_number (GtkSourceView *view,
        {
                if (!gtk_text_iter_starts_word (&start))
                {
+                       GtkTextIter prev;
+
                        gtk_text_iter_backward_word_start (&start);
+
+                       /* Include the negative sign if there is one.
+                        * https://gitlab.gnome.org/GNOME/gtksourceview/-/issues/117
+                        */
+                       prev = start;
+                       if (gtk_text_iter_backward_char (&prev) && gtk_text_iter_get_char (&prev) == '-')
+                       {
+                               start = prev;
+                       }
                }
 
                if (!gtk_text_iter_ends_word (&end))


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