[gnome-builder] code-assist: include the file suffix from the original file



commit 1864626127eab49c75c10142ecb4bc278d9e2301
Author: Christian Hergert <christian hergert me>
Date:   Tue Jan 6 15:59:20 2015 -0800

    code-assist: include the file suffix from the original file
    
    This can be handy when you want to see the file type in /tmp. Additionally,
    some code-assistance backends might make the mistake of using this suffix,
    so let's be resillient.

 src/code-assistant/gb-source-code-assistant.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/code-assistant/gb-source-code-assistant.c b/src/code-assistant/gb-source-code-assistant.c
index c9dee17..8ced9cc 100644
--- a/src/code-assistant/gb-source-code-assistant.c
+++ b/src/code-assistant/gb-source-code-assistant.c
@@ -423,11 +423,25 @@ gb_source_code_assistant_do_parse (gpointer data)
 
   if (!priv->tmpfile_path)
     {
+      const gchar *suffix;
+      gchar *template;
       int fd;
 
-      fd = g_file_open_tmp ("builder-code-assistant.XXXXXX",
-                            &priv->tmpfile_path,
-                            &error);
+      /*
+       * Generate a template filename that has still has the same suffix as
+       * the original filename. Some code-assistance backends will use this
+       * to modify how they are parsed.
+       */
+      suffix = strrchr (path, '.');
+      if (!suffix)
+        suffix = "";
+      template = g_strdup_printf ("builder-code-assistant-XXXXXX%s",
+                                  suffix);
+
+      fd = g_file_open_tmp (template,  &priv->tmpfile_path, &error);
+
+      g_free (template);
+
       if (fd == -1)
         {
           g_warning ("%s", error->message);


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