浏览代码

Kernel name optional chaining

Jeremy Tuloup 4 年之前
父节点
当前提交
0522b9fb52
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 3 3
      src/index.ts
  2. 1 1
      src/service.ts

+ 3 - 3
src/index.ts

@@ -554,7 +554,7 @@ const main: JupyterFrontEndPlugin<void> = {
         debuggerSources
           .find({
             focus: true,
-            kernel: service.session.connection.kernel.name,
+            kernel: service.session?.connection?.kernel?.name,
             path: service.session?.connection?.path,
             source: frame?.source.path ?? null
           })
@@ -575,8 +575,8 @@ const main: JupyterFrontEndPlugin<void> = {
         const { content, mimeType, path } = source;
         const results = debuggerSources.find({
           focus: true,
-          kernel: service.session.connection.kernel.name,
-          path: service.session.connection.path,
+          kernel: service.session?.connection?.kernel.name,
+          path: service.session?.connection?.path,
           source: path
         });
         if (results.length > 0) {

+ 1 - 1
src/service.ts

@@ -124,7 +124,7 @@ export class DebuggerService implements IDebugger, IDisposable {
    * @param code The source code.
    */
   getCodeId(code: string): string {
-    return this._config.getCodeId(code, this.session.connection.kernel.name);
+    return this._config.getCodeId(code, this.session?.connection?.kernel?.name);
   }
 
   /**