Procházet zdrojové kódy

Do not special-case logic for MainAreaWidget.

Since MainAreaWidget automatically reflects the title of the .content, we do not have to special-case logic for MainAreaWidgets.
Jason Grout před 4 roky
rodič
revize
686b6d3b22
1 změnil soubory, kde provedl 6 přidání a 14 odebrání
  1. 6 14
      packages/running-extension/src/opentabs.ts

+ 6 - 14
packages/running-extension/src/opentabs.ts

@@ -41,10 +41,8 @@ class OpenTabsSignaler {
    * @param widget A widget whose title may change.
    */
   addWidget(widget: Widget): void {
-    if (widget instanceof MainAreaWidget) {
-      widget.content.title.changed.connect(this._emitTabsChanged, this);
-      this._widgets.push(widget);
-    }
+    widget.title.changed.connect(this._emitTabsChanged, this);
+    this._widgets.push(widget);
   }
 
   /**
@@ -52,7 +50,7 @@ class OpenTabsSignaler {
    */
   private _emitTabsChanged(): void {
     this._widgets.forEach(widget => {
-      widget.content.title.changed.disconnect(this._emitTabsChanged, this);
+      widget.title.changed.disconnect(this._emitTabsChanged, this);
     });
     this._widgets = [];
     this._tabsChanged.emit(void 0);
@@ -60,7 +58,7 @@ class OpenTabsSignaler {
 
   private _tabsChanged = new Signal<this, void>(this);
   private _labShell: ILabShell;
-  private _widgets: MainAreaWidget[] = [];
+  private _widgets: Widget[] = [];
 }
 
 /**
@@ -113,14 +111,8 @@ export function addOpenTabsSessionManager(
       this._widget.close();
     }
     icon() {
-      let icon = fileIcon;
-      if (this._widget instanceof MainAreaWidget) {
-        const widgetIcon = this._widget.title.icon;
-        if (widgetIcon instanceof LabIcon) {
-          icon = widgetIcon as LabIcon;
-        }
-      }
-      return icon;
+      const widgetIcon = this._widget.title.icon;
+      return widgetIcon instanceof LabIcon ? widgetIcon : fileIcon;
     }
     label() {
       return this._widget.title.label;