[gtksourceview] styleschemepreview: recursively lookup fallbacks



commit c6c0253a59cd6298759f1a18e8b55280e4a517bc
Author: Christian Hergert <chergert redhat com>
Date:   Mon Oct 18 11:17:52 2021 -0700

    styleschemepreview: recursively lookup fallbacks
    
    We might have multiple fallbacks that need to be resolved rather than a
    single layer of them.
    
    Fixes #187

 gtksourceview/gtksourcestyleschemepreview.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/gtksourceview/gtksourcestyleschemepreview.c b/gtksourceview/gtksourcestyleschemepreview.c
index 83002106..dd1ab4ad 100644
--- a/gtksourceview/gtksourcestyleschemepreview.c
+++ b/gtksourceview/gtksourcestyleschemepreview.c
@@ -217,15 +217,16 @@ add_text (GtkSourceBuffer      *buffer,
 
                if (runs[i].style)
                {
-                       GtkSourceStyle *style = gtk_source_style_scheme_get_style (scheme, runs[i].style);
+                       const char *fallback = runs[i].style;
+                       GtkSourceStyle *style = NULL;
 
-                       if (style == NULL)
+                       while (style == NULL && fallback != NULL)
                        {
-                               const char *fallback = gtk_source_language_get_style_fallback (def, 
runs[i].style);
+                               style = gtk_source_style_scheme_get_style (scheme, fallback);
 
-                               if (fallback != NULL)
+                               if (style == NULL)
                                {
-                                       style = gtk_source_style_scheme_get_style (scheme, fallback);
+                                       fallback = gtk_source_language_get_style_fallback (def, fallback);
                                }
                        }
 


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