Selaa lähdekoodia

allowing line of text to be run in console based on cursor placement not just cursor selection

hjoo 8 vuotta sitten
vanhempi
commit
296e023952
1 muutettua tiedostoa jossa 5 lisäystä ja 1 poistoa
  1. 5 1
      packages/fileeditor-extension/src/index.ts

+ 5 - 1
packages/fileeditor-extension/src/index.ts

@@ -216,9 +216,13 @@ function activate(app: JupyterLab, registry: IDocumentRegistry, restorer: ILayou
       const selection = editor.getSelection();
       const start = editor.getOffsetAt(selection.start);
       const end = editor.getOffsetAt(selection.end);
+      let targetText = editor.model.value.text.substring(start, end);
+      if (start == end) {
+        targetText = editor.getLine(selection.start.line); 
+      }
       const options: JSONObject = {
         path: widget.context.path,
-        code: editor.model.value.text.substring(start, end),
+        code: targetText,
         activate: args['activate']
       };
       return commands.execute('console:inject', options);