Browse Source

Merge pull request #2125 from blink1073/fix-run-code

Fix running code from the editor
S. Chris Colbert 8 years ago
parent
commit
867bdd131b
2 changed files with 3 additions and 22 deletions
  1. 1 2
      packages/editorwidget/package.json
  2. 2 20
      packages/editorwidget/src/index.ts

+ 1 - 2
packages/editorwidget/package.json

@@ -18,8 +18,7 @@
     "@jupyterlab/coreutils": "^0.3.1",
     "@jupyterlab/docregistry": "^0.3.1",
     "@phosphor/commands": "^1.0.0",
-    "@phosphor/coreutils": "^1.0.0",
-    "@phosphor/properties": "^1.0.0"
+    "@phosphor/coreutils": "^1.0.0"
   },
   "devDependencies": {
     "rimraf": "^2.5.2",

+ 2 - 20
packages/editorwidget/src/index.ts

@@ -9,10 +9,6 @@ import {
   JSONObject, Token
 } from '@phosphor/coreutils';
 
-import {
-  AttachedProperty
-} from '@phosphor/properties';
-
 import {
   IInstanceTracker
 } from '@jupyterlab/apputils';
@@ -73,14 +69,6 @@ function addDefaultCommands(tracker: IEditorTracker, commands: CommandRegistry)
     }
   }
 
-  /**
-   * An attached property for the session id associated with an editor widget.
-   */
-  const sessionIdProperty = new AttachedProperty<EditorWidget, string>({
-    name: 'sessionId',
-    create: () => ''
-  });
-
   commands.addCommand('editor:line-numbers', {
     execute: args => { toggleLineNums(args); },
     label: 'Toggle Line Numbers'
@@ -102,8 +90,7 @@ function addDefaultCommands(tracker: IEditorTracker, commands: CommandRegistry)
         preferredLanguage: widget.context.model.defaultKernelLanguage,
         activate: args['activate']
       };
-      return commands.execute('console:create', options)
-        .then(id => { sessionIdProperty.set(widget, id); });
+      return commands.execute('console:create', options);
     },
     label: 'Create Console for Editor'
   });
@@ -114,18 +101,13 @@ function addDefaultCommands(tracker: IEditorTracker, commands: CommandRegistry)
       if (!widget) {
         return;
       }
-      // Get the session id.
-      let id = sessionIdProperty.get(widget);
-      if (!id) {
-        return;
-      }
       // Get the selected code from the editor.
       const editor = widget.editor;
       const selection = editor.getSelection();
       const start = editor.getOffsetAt(selection.start);
       const end = editor.getOffsetAt(selection.end);
       const options: JSONObject = {
-        id,
+        path: widget.context.path,
         code: editor.model.value.text.substring(start, end),
         activate: args['activate']
       };