You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Shift + Enter shortcut ("Send Selection To Interactive Window") allows you to send small executable blocks of code to your terminal. This is helpful when you want to execute just one line or function and not your entire file.
For example, if you have a function
def foo():
print("A")
print("B")
and just put your cursor on the def foo(): line (or select the entire function code), the function defenition of foo() will be sent to your terminal and executed. VSCode does this in a smart way which ensures that you do not get an IndentationError: unexpected indent like you would get if you just copy-pasted the function definition in the terminal.
This breaks if you include triple quotes (""") or (''') anywhere in your function. VSCode still recognizes the entire function as the entity it wants to execute, and tries to send it to the terminal, but now fails to handle empty lines smartly and raises an IndentationError: unexpected indent.
It does not matter whether the pythonREPLSmartSend setting is enabled or not.
Steps to Reproduce:
Create a new python file
Define a function in which a new line occurs, e.g.
def this_works():
print("A")
print("B")
Put your cursor on the function definition or select the function and press Shift + Enter
This handles the empty line well and defines the function in your terminal
Define a function in which a triple quote occurs, e.g.
def this_breaks_a():
"""This function breaks"""
print("A")
print("B")
or even
def this_breaks_b():
print("A ''' B")
print("B")
Put your cursor on the function definition or select the function and press Shift + Enter
VSCode sends the code to your Terminal, but raises an IndentationError: unexpected indent
The text was updated successfully, but these errors were encountered:
From what I can tell, this works in the interactive window but breaks in the terminal.
I assume because the terminal is getting the lines one at a time, and the blank line makes it think the code is finished and should be run (because of the new >>> on the errored line).
amunger
changed the title
[BUG] "Send Selection To Interactive Window" (Shift + Enter) breaks when encountering triple quotes (Python REPL)
[BUG] (Shift + Enter) breaks when encountering triple quotes (Python REPL)
Sep 11, 2024
Can folks please try the latest pre-release version of the Python extension and let me know if the problem is resolved?
Want to make sure before deploying reverted changes to stable. - Thanks
Does this issue occur when all extensions are disabled?: Yes
Version: 1.92.2 (system setup)
Commit: fee1edb8d6d72a0ddff41e5f71a671c23ed924b9
Date: 2024-08-14T17:29:30.058Z
Electron: 30.1.2
ElectronBuildId: 9870757
Chromium: 124.0.6367.243
Node.js: 20.14.0
V8: 12.4.254.20-electron.0
Windows_NT x64 10.0.22621
Description
The Shift + Enter shortcut ("Send Selection To Interactive Window") allows you to send small executable blocks of code to your terminal. This is helpful when you want to execute just one line or function and not your entire file.
For example, if you have a function
and just put your cursor on the
def foo():
line (or select the entire function code), the function defenition of foo() will be sent to your terminal and executed. VSCode does this in a smart way which ensures that you do not get anIndentationError: unexpected indent
like you would get if you just copy-pasted the function definition in the terminal.This breaks if you include triple quotes (""") or (''') anywhere in your function. VSCode still recognizes the entire function as the entity it wants to execute, and tries to send it to the terminal, but now fails to handle empty lines smartly and raises an
IndentationError: unexpected indent
.It does not matter whether the
pythonREPLSmartSend
setting is enabled or not.Steps to Reproduce:
or even
IndentationError: unexpected indent
The text was updated successfully, but these errors were encountered: