浏览代码

Fix tests.

Ian Rose 8 年之前
父节点
当前提交
77443b542c
共有 2 个文件被更改,包括 8 次插入2 次删除
  1. 6 0
      packages/codemirror/src/editor.ts
  2. 2 2
      packages/notebook/src/widget.ts

+ 6 - 0
packages/codemirror/src/editor.ts

@@ -414,6 +414,12 @@ class CodeMirrorEditor implements CodeEditor.IEditor {
   setCursorPosition(position: CodeEditor.IPosition): void {
     const cursor = this._toCodeMirrorPosition(position);
     this.doc.setCursor(cursor);
+    // If the editor does not have focus, this cursor change
+    // will get screened out in _onCursorsChanged(). Make an
+    // exception for this method.
+    if (!this.editor.hasFocus()) {
+      this.model.selections.set(this.uuid, this.getSelections());
+    }
   }
 
   /**

+ 2 - 2
packages/notebook/src/widget.ts

@@ -210,7 +210,7 @@ class StaticNotebook extends Widget {
           this._onCollaboratorsChanged, this);
       });
     }
-    if (newValue.modelDB.isCollaborative) {
+    if (newValue && newValue.modelDB.isCollaborative) {
       newValue.modelDB.connected.then(() => {
         newValue.modelDB.collaborators.changed.connect(
           this._onCollaboratorsChanged, this);
@@ -960,7 +960,7 @@ class Notebook extends StaticNotebook {
    * Handle a cell being inserted.
    */
   protected onCellInserted(index: number, cell: Cell): void {
-    if (this.model.modelDB.isCollaborative) {
+    if (this.model && this.model.modelDB.isCollaborative) {
       let modelDB = this.model.modelDB;
       modelDB.connected.then(() => {
         if (!cell.isDisposed) {