Browse Source

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

hjoo 8 năm trước cách đây
mục cha
commit
296e023952
1 tập tin đã thay đổi với 5 bổ sung1 xóa
  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);