[gnome-builder] gui: resolve workbench from ide_workbench_open_at_async()



commit 2b9befb26aeddeb0331fc4e9a23cbd284388e63a
Author: Christian Hergert <chergert redhat com>
Date:   Fri Jan 18 11:04:45 2019 -0800

    gui: resolve workbench from ide_workbench_open_at_async()
    
    We might want to open the file in another workbench. If we detect a
    workbench with a closer match, use it.

 src/libide/gui/ide-workbench.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/src/libide/gui/ide-workbench.c b/src/libide/gui/ide-workbench.c
index de9439b6a..b5137218a 100644
--- a/src/libide/gui/ide-workbench.c
+++ b/src/libide/gui/ide-workbench.c
@@ -1953,6 +1953,7 @@ ide_workbench_open_at_async (IdeWorkbench        *self,
 {
   g_autoptr(IdeTask) task = NULL;
   g_autoptr(GPtrArray) addins = NULL;
+  IdeWorkbench *other;
   Open *o;
 
   g_return_if_fail (IDE_IS_WORKBENCH (self));
@@ -1960,6 +1961,25 @@ ide_workbench_open_at_async (IdeWorkbench        *self,
   g_return_if_fail (self->unloaded == FALSE);
   g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
 
+  /* Possibly re-route opening the file to another workbench if we
+   * discover the file is a better fit over there.
+   */
+  other = ide_application_find_workbench_for_file (IDE_APPLICATION_DEFAULT, file);
+
+  if (other != NULL && other != self)
+    {
+      ide_workbench_open_at_async (other,
+                                   file,
+                                   hint,
+                                   at_line,
+                                   at_line_offset,
+                                   flags,
+                                   cancellable,
+                                   callback,
+                                   user_data);
+      return;
+    }
+
   /* Canonicalize parameters */
   if (at_line < 0)
     at_line = -1;


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