Browse Source

Backport PR #12507: Ensure settings editor is attached before activation (#12514)

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
MeeseeksMachine 3 years ago
parent
commit
06e043de7c
1 changed files with 8 additions and 2 deletions
  1. 8 2
      packages/settingeditor-extension/src/index.ts

+ 8 - 2
packages/settingeditor-extension/src/index.ts

@@ -107,7 +107,10 @@ function activate(
 
   commands.addCommand(CommandIDs.open, {
     execute: async args => {
-      if (tracker.currentWidget) {
+      if (tracker.currentWidget && !tracker.currentWidget.isDisposed) {
+        if (!tracker.currentWidget.isAttached) {
+          shell.add(tracker.currentWidget);
+        }
         shell.activateById(tracker.currentWidget.id);
         return;
       }
@@ -218,7 +221,10 @@ function activateJSON(
 
   commands.addCommand(CommandIDs.openJSON, {
     execute: async () => {
-      if (tracker.currentWidget) {
+      if (tracker.currentWidget && !tracker.currentWidget.isDisposed) {
+        if (!tracker.currentWidget.isAttached) {
+          shell.add(tracker.currentWidget);
+        }
         shell.activateById(tracker.currentWidget.id);
         return;
       }