Browse Source

Merge pull request #232 from afshin/issue-231

Fixes #231
Jason Grout 9 years ago
parent
commit
d92fec0d28
3 changed files with 8 additions and 7 deletions
  1. 1 4
      examples/console/package.json
  2. 1 1
      examples/notebook/package.json
  3. 6 2
      src/notebook/console/widget.ts

+ 1 - 4
examples/console/package.json

@@ -20,12 +20,9 @@
   "dependencies": {
     "jupyter-js-notebook": "file:../..",
     "jupyter-js-services": "^0.10.4",
-    "jupyter-js-ui": "^0.13.0",
-    "jupyter-js-utils": "^0.4.0",
+    "jupyter-js-ui": "^0.14.0",
     "phosphor-commandpalette": "^0.2.0",
-    "phosphor-disposable": "^1.0.5",
     "phosphor-keymap": "^0.8.0",
-    "phosphor-signaling": "^1.2.0",
     "phosphor-splitpanel": "^1.0.0-rc.1",
     "phosphor-widget": "^1.0.0-rc.1"
   }

+ 1 - 1
examples/notebook/package.json

@@ -20,7 +20,7 @@
   "dependencies": {
     "jupyter-js-notebook": "file:../..",
     "jupyter-js-services": "^0.10.4",
-    "jupyter-js-ui": "^0.13.0",
+    "jupyter-js-ui": "^0.14.0",
     "phosphor-commandpalette": "^0.2.0",
     "phosphor-keymap": "^0.8.0",
     "phosphor-splitpanel": "^1.0.0-rc.1",

+ 6 - 2
src/notebook/console/widget.ts

@@ -564,9 +564,13 @@ class ConsoleWidget extends Widget {
    * Handle a completion selected signal from the completion widget.
    */
   protected onCompletionSelect(widget: CompletionWidget, value: string): void {
+    let prompt = this.prompt;
     let patch = this._completion.model.createPatch(value);
-    let editor = this.prompt.editor.editor;
-    let doc = editor.getDoc();
+    let doc = prompt.editor.editor.getDoc();
+    // Update the prompt model.
+    prompt.model.source = patch.text;
+    // Because the prompt model triggers a DOM update asynchronously,
+    // CodeMirror value and position need to be set manually (synchronously).
     doc.setValue(patch.text);
     doc.setCursor(doc.posFromIndex(patch.position));
   }