Преглед изворни кода

Fix findwidget for Editor widgetName

Jeremy Tuloup пре 6 година
родитељ
комит
4eafd840dc
1 измењених фајлова са 9 додато и 8 уклоњено
  1. 9 8
      packages/docmanager/src/manager.ts

+ 9 - 8
packages/docmanager/src/manager.ts

@@ -290,18 +290,19 @@ export class DocumentManager implements IDisposable {
     widgetName = 'default'
   ): IDocumentWidget | undefined {
     let newPath = PathExt.normalize(path);
+    let widgetNames = [widgetName];
     if (widgetName === 'default') {
-      let factory = this.registry.defaultWidgetFactory(newPath);
-      if (!factory) {
-        return undefined;
-      }
-      widgetName = factory.name;
+      widgetNames = this.registry
+        .preferredWidgetFactories(newPath)
+        .map(f => f.name);
     }
 
     for (let context of this._contextsForPath(newPath)) {
-      let widget = this._widgetManager.findWidget(context, widgetName);
-      if (widget) {
-        return widget;
+      for (const widgetName of widgetNames) {
+        let widget = this._widgetManager.findWidget(context, widgetName);
+        if (widget) {
+          return widget;
+        }
       }
     }
     return undefined;