[gnome-builder] code: default to python3 when guessing languages



commit 3063850e955410ba24c5b12b885aceb1b50f3fd3
Author: Christian Hergert <chergert redhat com>
Date:   Sun Sep 6 22:45:58 2020 -0700

    code: default to python3 when guessing languages
    
    Until we can get reliable guessing from shared-mime-info, default to
    python3.

 src/libide/code/ide-buffer.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/src/libide/code/ide-buffer.c b/src/libide/code/ide-buffer.c
index 9df02da72..0afa3c12e 100644
--- a/src/libide/code/ide-buffer.c
+++ b/src/libide/code/ide-buffer.c
@@ -3597,6 +3597,7 @@ ide_buffer_guess_language (IdeBuffer *self)
   g_autofree gchar *basename = NULL;
   g_autofree gchar *content_type = NULL;
   g_autofree gchar *line = NULL;
+  const gchar *lang_id;
   const gchar *path;
   GFile *file;
   gboolean uncertain = FALSE;
@@ -3626,7 +3627,18 @@ ide_buffer_guess_language (IdeBuffer *self)
       !(lang = gtk_source_language_manager_guess_language (manager, basename, content_type)))
     return;
 
-  if (!ide_str_equal0 (gtk_source_language_get_id (lang), ide_buffer_get_language_id (self)))
+  lang_id = gtk_source_language_get_id (lang);
+
+  /* Override to python3 by default for now, until shared-mime-info
+   * gets a better way to detect the difference between the two.
+   */
+  if (ide_str_equal0 (lang_id, "python"))
+    {
+      lang_id = "python3";
+      lang = gtk_source_language_manager_get_language (manager, lang_id);
+    }
+
+  if (!ide_str_equal0 (lang_id, ide_buffer_get_language_id (self)))
     gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (self), lang);
 }
 


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