Ver código fonte

Account for selecting no kernel

Steven Silvester 9 anos atrás
pai
commit
21d396ff7b
2 arquivos alterados com 11 adições e 2 exclusões
  1. 7 1
      src/docmanager/context.ts
  2. 4 1
      src/docmanager/interfaces.ts

+ 7 - 1
src/docmanager/context.ts

@@ -343,8 +343,14 @@ class ContextManager implements IDisposable {
         kernelId: options.id
       };
       return this._startSession(id, sOptions);
-    } else {
+    } else if (options) {
       return session.changeKernel(options);
+    } else if (session) {
+      return session.shutdown().then(() => {
+        session.dispose();
+        contextEx.session = null;
+        return void 0;
+      });
     }
   }
 

+ 4 - 1
src/docmanager/interfaces.ts

@@ -167,8 +167,11 @@ export interface IDocumentContext extends IDisposable {
 
   /**
    * Change the current kernel associated with the document.
+   *
+   * #### Notes
+   * If no options are given, the session is shut down.
    */
-  changeKernel(options: IKernelId): Promise<IKernel>;
+  changeKernel(options?: IKernelId): Promise<IKernel>;
 
   /**
    * Save the document contents to disk.