浏览代码

Clean up remaining logic errors

Steven Silvester 8 年之前
父节点
当前提交
537609b61b
共有 6 个文件被更改,包括 26 次插入24 次删除
  1. 1 1
      src/completer/handler.ts
  2. 1 1
      src/completer/widget.ts
  3. 13 11
      src/console/panel.ts
  4. 1 1
      src/console/widget.ts
  5. 6 6
      src/notebook/notebook/panel.ts
  6. 4 4
      src/shortcuts/plugin.ts

+ 1 - 1
src/completer/handler.ts

@@ -134,7 +134,7 @@ class CellCompleterHandler implements IDisposable {
       coords,
       line: position.line,
       column: position.column
-    }
+    };
   }
 
   /**

+ 1 - 1
src/completer/widget.ts

@@ -86,7 +86,7 @@ class CompleterWidget extends Widget {
     super({ node: document.createElement('ul') });
     this._renderer = options.renderer || CompleterWidget.defaultRenderer;
     this.anchor = options.anchor || null;
-    this.model = options.model || null;
+    this.model = options.model;
     this.addClass(COMPLETER_CLASS);
 
     // Completer widgets are hidden until they are populated.

+ 13 - 11
src/console/panel.ts

@@ -26,7 +26,7 @@ import {
 } from '../codeeditor';
 
 import {
-  CellCompleterHandler, CompleterWidget
+  CellCompleterHandler, CompleterModel, CompleterWidget
 } from '../completer';
 
 import {
@@ -77,7 +77,7 @@ class ConsolePanel extends Panel {
     });
 
     // Instantiate the completer.
-    this._completer = factory.createCompleter({});
+    this._completer = factory.createCompleter({ model: new CompleterModel() });
 
     // Set the completer widget's anchor node to peg its position.
     this._completer.anchor = this.node;
@@ -108,6 +108,13 @@ class ConsolePanel extends Panel {
    */
   readonly inspectionHandler: InspectionHandler;
 
+  /**
+   * Test whether the widget is disposed.
+   */
+  get isDisposed(): boolean {
+    return this._completer == null;
+  }
+
   /**
    * Dispose of the resources held by the widget.
    */
@@ -115,17 +122,13 @@ class ConsolePanel extends Panel {
     if (this.isDisposed) {
       return;
     }
-
-    // Dispose console widget.
-    this._content.dispose();
-    this._content = null;
-
+    let completer = this._completer;
+    this._completer = null;
+    completer.dispose();
+    this.console.dispose();
     this._completerHandler.dispose();
     this._completerHandler = null;
-    this._completer.dispose();
-    this._completer = null;
     this.inspectionHandler.dispose();
-
     super.dispose();
   }
 
@@ -163,7 +166,6 @@ class ConsolePanel extends Panel {
     this.inspectionHandler.kernel = kernel;
   }
 
-  private _content: CodeConsole = null;
   private _completer: CompleterWidget = null;
   private _completerHandler: CellCompleterHandler = null;
 

+ 1 - 1
src/console/widget.ts

@@ -613,7 +613,7 @@ class CodeConsole extends Widget {
    * Handle a keydown event on an editor.
    */
   private _onEditorKeydown(editor: CodeEditor.IEditor, event: KeyboardEvent) {
-    // Suppres "Enter" events.
+    // Suppress "Enter" events.
     return event.keyCode === 13;
   }
 

+ 6 - 6
src/notebook/notebook/panel.ts

@@ -50,7 +50,7 @@ import {
 } from '../../rendermime';
 
 import {
-  CompleterWidget, CellCompleterHandler
+  CompleterModel, CompleterWidget, CellCompleterHandler
 } from '../../completer';
 
 import {
@@ -117,15 +117,14 @@ class NotebookPanel extends Widget {
 
     // Set up the inspection handler.
     this.inspectionHandler = factory.createInspectionHandler({
-      kernel: this.context.kernel,
       rendermime: this.rendermime
     });
 
     // Instantiate the completer.
-    this._completer = factory.createCompleter({});
+    this._completer = factory.createCompleter({ model: new CompleterModel() });
 
     // Set the completer widget's anchor node to peg its position.
-    this._completer.anchor = this.node;
+    this._completer.anchor = this.notebook.node;
 
     // Because a completer widget may be passed in, check if it is attached.
     if (!this._completer.isAttached) {
@@ -134,9 +133,9 @@ class NotebookPanel extends Widget {
 
     // Instantiate the completer handler.
     this._completerHandler = factory.createCompleterHandler({
-      completer: this._completer,
-      kernel: this.context.kernel
+      completer: this._completer
     });
+    this._completerHandler.activeCell = this.notebook.activeCell;
   }
 
   /**
@@ -376,6 +375,7 @@ class NotebookPanel extends Widget {
    */
   private _onActiveCellChanged(sender: Notebook, widget: BaseCellWidget) {
     this.inspectionHandler.activeCell = widget;
+    this._completerHandler.activeCell = widget;
   }
 
   private _completer: CompleterWidget = null;

+ 4 - 4
src/shortcuts/plugin.ts

@@ -257,22 +257,22 @@ const SHORTCUTS = [
   },
   {
     command: 'console:run',
-    selector: '.jp-ConsoleContent-prompt',
+    selector: '.jp-CodeConsole-prompt',
     keys: ['Enter']
   },
   {
     command: 'console:run-forced',
-    selector: '.jp-ConsoleContent-prompt',
+    selector: '.jp-CodeConsole-prompt',
     keys: ['Shift Enter']
   },
   {
     command: 'console:linebreak',
-    selector: '.jp-ConsoleContent-prompt',
+    selector: '.jp-CodeConsole-prompt',
     keys: ['Ctrl Enter']
   },
   {
     command: 'console:toggle-inspectors',
-    selector: '.jp-ConsoleContent-promptt',
+    selector: '.jp-CodeConsole-promptt',
     keys: ['Accel I']
   },
   {