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
Hello, I am working on improving REPL and Terminal experience for people using VS Code Python, and we have been experiencing the indentation issue similar to one you would see in #124096.
I do realize there are indentation error issue mentioned such as one above, but I wasn't sure if it is rooted from same problem since the one in #124096 is Windows, and I am seeing it on MacOS ARM (tested on zsh, xterm.js since we are talking about terminal in VS Code).
From what I've seen, the indentation gets messed up when we programmatically send a indented string into the 3.13 REPL launched from the VS Code Terminal. If I were to send the exact same Python code to 3.13 and to non-3.13(such as 3.9) REPL programmatically, it will lead to two different result:
One from Python3.9 (or non-3.13) will be fine, but code sent to 3.13 REPL will suffer from additional indentation as you see below:
What I found surprising during my investigation is that copy-pasting the exact same code, works fine when I manually copy and paste to external Terminal (Both outside of VS Code and also inside VS Code Terminal)
I'm suspecting that there are either:
Magical copy-paste detection mechanism built into 3.13 REPL (such via custom sequences or some environment variable) that VS Code is missing to do.
Something in the new auto-identation that does not accept programmatic send of text to REPL that does not respect pre-idented Python code to be run.
Another issue related to 3.13 REPL in VS Code: #126131
The REPL accepts interactive input and automatically indents. How is that a bug? Do you have a suggestion how a TTY application is supposed to automatically discover "programmatic input"? AFAICT this is what bracketed paste is for, it's literally for pre-formatted input.
Thanks everyone for your help. I've just recently merged some changes in the vscode-python repo with the suggested bracketed paste mode and things are looking good so far :)
Activity
brettcannon commentedon Nov 5, 2024
And /cc @ambv
ambv commentedon Nov 5, 2024
@anthonykim1, you can programatically paste code using bracketed pasting, in which case additional indentation won't be inserted by the REPL.
Tyriar commentedon Nov 5, 2024
@ambv that sounds like a workaround that might work for us, but the content is not pasted and you shouldn't need to do that (this is a bug).ambv commentedon Nov 5, 2024
The REPL accepts interactive input and automatically indents. How is that a bug? Do you have a suggestion how a TTY application is supposed to automatically discover "programmatic input"? AFAICT this is what bracketed paste is for, it's literally for pre-formatted input.
Tyriar commentedon Nov 6, 2024
@ambv oh sorry I thought this was #126131 😅 you're right. Bracketed paste mode is the right fix here on our end
add bracketed paste mode for Python3.13 and above (#24401)
anthonykim1 commentedon Nov 12, 2024
Thanks everyone for your help. I've just recently merged some changes in the vscode-python repo with the suggested bracketed paste mode and things are looking good so far :)