[gtksourceview] regex: ignore secondary match failures



commit 4c2711a310607a945f1b7e0478908ebb9dc2e651
Author: Christian Hergert <chergert redhat com>
Date:   Tue Mar 2 10:42:54 2021 -0800

    regex: ignore secondary match failures
    
    If we already matched once, then we can consider the match a success and
    ignore the followup error.
    
    This fixes an issue with loading some syntax files such as TypeScript.

 gtksourceview/implregex.c | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/gtksourceview/implregex.c b/gtksourceview/implregex.c
index 70ab2eee..8d1ffb94 100644
--- a/gtksourceview/implregex.c
+++ b/gtksourceview/implregex.c
@@ -395,6 +395,13 @@ impl_regex_replace_eval (const ImplRegex        *regex,
                done = (*eval) (match_info, result, user_data);
                str_pos = match_info->offsets[1];
                impl_match_info_next (match_info, &tmp_error);
+
+               /* We already matched, so ignore future matches */
+               if (g_error_matches (tmp_error, G_REGEX_ERROR, G_REGEX_ERROR_MATCH))
+               {
+                       g_clear_error (&tmp_error);
+                       break;
+               }
        }
 
        impl_match_info_free (match_info);


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