[gtksourceview] Bracket matching: fix subtle bug with lost context class



commit 28157129aa76a861853b730854b01d1e46c3794c
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Sat Oct 24 13:42:00 2015 +0200

    Bracket matching: fix subtle bug with lost context class

 gtksourceview/gtksourcebuffer.c |    7 ++-----
 tests/test-buffer.c             |    4 ----
 2 files changed, 2 insertions(+), 9 deletions(-)
---
diff --git a/gtksourceview/gtksourcebuffer.c b/gtksourceview/gtksourcebuffer.c
index c297c58..4835c40 100644
--- a/gtksourceview/gtksourcebuffer.c
+++ b/gtksourceview/gtksourcebuffer.c
@@ -1221,17 +1221,14 @@ find_bracket_match_real (GtkSourceBuffer *buffer,
 
                /* Check if we lost a class, which means we don't look any
                 * further.
-                * FIXME: bug if context class changes directly from comment to
-                * string and then from string to comment. Brackets in the
-                * second comment will match with brackets in the first comment.
                 */
-               if (cur_mask < cclass_mask)
+               if ((cclass_mask & cur_mask) != cclass_mask)
                {
                        found = FALSE;
                        break;
                }
 
-               if (cur_mask != cclass_mask)
+               if (cclass_mask != cur_mask)
                {
                        continue;
                }
diff --git a/tests/test-buffer.c b/tests/test-buffer.c
index e9e9480..60eecc0 100644
--- a/tests/test-buffer.c
+++ b/tests/test-buffer.c
@@ -396,16 +396,12 @@ test_bracket_matching (void)
        do_test_bracket_matching (buffer, "/*(*/ /*)*/", 8, -1, -1, GTK_SOURCE_BRACKET_MATCH_NOT_FOUND);
 
        /* Direct changes: string -> comment -> string */
-       /* FIXME works by chance */
        do_test_bracket_matching (buffer, "\"(\"/*a*/\")\"", 1, -1, -1, GTK_SOURCE_BRACKET_MATCH_NOT_FOUND);
        do_test_bracket_matching (buffer, "\"(\"/*a*/\")\"", 9, -1, -1, GTK_SOURCE_BRACKET_MATCH_NOT_FOUND);
 
        /* Direct changes: comment -> string -> comment */
-       /* FIXME */
-#if 0
        do_test_bracket_matching (buffer, "/*(*/\"a\"/*)*/", 2, -1, -1, GTK_SOURCE_BRACKET_MATCH_NOT_FOUND);
        do_test_bracket_matching (buffer, "/*(*/\"a\"/*)*/", 10, -1, -1, GTK_SOURCE_BRACKET_MATCH_NOT_FOUND);
-#endif
 
        g_object_unref (buffer);
 }


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