[gnome-builder/gnome-builder-3-26] sourceview: ensure indenter is disabled



commit 8b5397c0947eca2257075a79a019cd25faf006ef
Author: Christian Hergert <chergert redhat com>
Date:   Mon Oct 16 02:06:59 2017 -0700

    sourceview: ensure indenter is disabled
    
    When auto-indent is set to FALSE, we want to be sure that the
    indenter is disabled. So clear our extension match until it
    has been re-enabled or the language changed.

 libide/sourceview/ide-source-view.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/libide/sourceview/ide-source-view.c b/libide/sourceview/ide-source-view.c
index 3c8328b..d040018 100644
--- a/libide/sourceview/ide-source-view.c
+++ b/libide/sourceview/ide-source-view.c
@@ -851,10 +851,23 @@ static void
 ide_source_view_update_auto_indent_override (IdeSourceView *self)
 {
   IdeSourceViewPrivate *priv = ide_source_view_get_instance_private (self);
+  GtkSourceLanguage *language;
+  const gchar *lang_id = NULL;
   IdeIndenter *indenter;
 
   g_assert (IDE_IS_SOURCE_VIEW (self));
 
+  /* Update the indenter if necessary */
+  if (priv->auto_indent &&
+      priv->indenter_adapter != NULL &&
+      priv->buffer != NULL &&
+      NULL != (language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (priv->buffer))))
+    lang_id = gtk_source_language_get_id (language);
+
+  if (priv->indenter_adapter != NULL)
+    ide_extension_adapter_set_value (priv->indenter_adapter, lang_id);
+
+  /* Fetch our indenter */
   indenter = ide_source_view_get_indenter (self);
 
   /*


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