Replies: 2 comments
-
There is a loosely related discussion over in #15151, but that one relies on explicit cell markup and Jupyter-specific capabilities. What I'm proposing here is for plain Python and does not rely on markup or Jupyter. It's just an enhancement to the existing "Run Selection/Line in Python Terminal" feature. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Moved to #17209 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Consider this little example:
Say my cursor is on the line that contains
.conf()
, with no text highlighted. If I hitShift + Enter
(python.execSelectionInTerminal
), then only the.conf()
line will be sent to the terminal, and it will fail with a syntax error.What I want is to run the complete block of code, starting with
spark =
and going all the way to the closing parenthesis. To do that today, I need to highlight all the lines myself.It would be great if this extension automatically detected and ran the block of code surrounding the current cursor position, specifically in the case where no text is highlighted. That way I could place my cursor anywhere inside the above example block of code, hit
Shift + Enter
, and the entire block of code will be sent to the terminal. I don't need to explicitly highlight the lines myself.Having this ability lends to a more Jupyter-like experience, without needing to define explicit cells or move to notebooks. And it makes it much easier and quicker to send multi-line units of code -- like the above example, or function definitions, or
if
blocks, etc. -- to the terminal.It seems like the extension should have enough information to correctly detect the block of code surrounding the current cursor position. In fact, if you move your cursor somewhere inside the above block of code and repeatedly run "Expand Selection" (
editor.action.smartSelect.expand
) it will incrementally grow the selection until the whole block is selected. Perhaps the underlying machinery can be reused to implement this idea.Beta Was this translation helpful? Give feedback.
All reactions