浏览代码

Re-order activeCell check

Jeremy Tuloup 5 年之前
父节点
当前提交
c036b1f9fc
共有 1 个文件被更改,包括 11 次插入9 次删除
  1. 11 9
      src/handlers/cell.ts

+ 11 - 9
src/handlers/cell.ts

@@ -48,21 +48,23 @@ export class CellManager implements IDisposable {
   isDisposed: boolean;
 
   private showCurrentLine(lineNumber: number) {
-    if (this.activeCell) {
-      const editor = this.activeCell.editor as CodeMirrorEditor;
-      this.cleanupHighlight();
-      editor.editor.addLineClass(lineNumber - 1, 'wrap', LINE_HIGHLIGHT_CLASS);
+    if (!this.activeCell) {
+      return;
     }
+    const editor = this.activeCell.editor as CodeMirrorEditor;
+    this.cleanupHighlight();
+    editor.editor.addLineClass(lineNumber - 1, 'wrap', LINE_HIGHLIGHT_CLASS);
   }
 
   // TODO: call when the debugger stops
   private cleanupHighlight() {
-    if (this.activeCell) {
-      const editor = this.activeCell.editor as CodeMirrorEditor;
-      editor.doc.eachLine(line => {
-        editor.editor.removeLineClass(line, 'wrap', LINE_HIGHLIGHT_CLASS);
-      });
+    if (!this.activeCell) {
+      return;
     }
+    const editor = this.activeCell.editor as CodeMirrorEditor;
+    editor.doc.eachLine(line => {
+      editor.editor.removeLineClass(line, 'wrap', LINE_HIGHLIGHT_CLASS);
+    });
   }
 
   dispose(): void {