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
{{ message }}
Repository navigation
SmartSend removes empty lines with triple-quoted strings #23743
SmartSend on a triple-quoted string containing empty lines (i.e. two or more subsequent \n) removes empty lines on execution.
Steps to reproduce:
Hit Shift-Enter on the following string:
"""HelloWorldHow are you?"""
The result is:
'Hello\nWorld\nHow are you?'
The expected result is:
'Hello\n\nWorld\n\n\n\n\nHow are you?'
Diagnostic data
Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)
2024-07-04 08:42:46.921 [info] Telemetry level is off
2024-07-04 08:42:46.921 [info] Experiments are disabled, only manually opted experiments are active.
2024-07-04 08:42:46.921 [info] Python interpreter path: ~/.pyenv/versions/3.12.4/envs/temp/bin/python
2024-07-04 08:42:47.743 [info] Starting Pylance language server.
2024-07-04 08:42:49.160 [info] > ~/.pyenv/versions/3.12.4/envs/temp/bin/python ~/.vscode/extensions/ms-python.python-2024.9.2024062703-darwin-arm64/python_files/normalizeSelection.py
2024-07-04 08:42:49.307 [info] Send text to terminal: /Users/clemens/.pyenv/versions/3.12.4/envs/temp/bin/python
2024-07-04 08:47:40.793 [info] > ~/.pyenv/versions/3.12.4/envs/temp/bin/python ~/.vscode/extensions/ms-python.python-2024.9.2024062703-darwin-arm64/python_files/normalizeSelection.py
2024-07-04 08:47:40.827 [info] Send text to terminal: """Hello
World
How are you?"""
Extension version: 2024.9.2024062703
VS Code version: Code 1.91.0 (ea1445cc7016315d0f5728f8e8b12a45dc0a7286, 2024-07-01T18:53:23.353Z)
OS version: Darwin arm64 23.5.0
Modes:
Clemens Brunner (@cbrnr) Hello! Thank you for filing the issue. I believe this is expected behavior as we "normalize" white spaces to send to terminal and REPL. I think you should be able to repro this even when you turn off smart send, if I recall correctly.
Yes, I can reproduce the behavior also when SmartSend is off. However, I do not think that this is expected behavior. Executing a command should not modify ("normalize") the contents of a string, which is what is happening here. So to me, this is clearly a bug.
I would tend to agree with Clemens Brunner (@cbrnr) here: if I send something to the REPL, it should not get modified. If I intended to print this string, suddenly some intentionally empty lines would be gone -- surely this cannot be right!
Good news folks. Managed to get this in August plan, so I will be investigating how to best handle this normalization of command when we send it to either terminal REPL or native REPL!
Hi folks! Just merged in the PR for this, that being said it should be available starting tomorrow's(August 21st) pre-release of the Python extension. Give this a try via running shift+enter on your multi line string or even an assignment to the multi-line string. Thank you all :)
Reacted by Richard Höchenberger and Clemens Brunner
Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.
Activity
anthonykim1 commentedon Jul 15, 2024
Clemens Brunner (@cbrnr) Hello! Thank you for filing the issue. I believe this is expected behavior as we "normalize" white spaces to send to terminal and REPL. I think you should be able to repro this even when you turn off smart send, if I recall correctly.
cbrnr commentedon Jul 16, 2024
Yes, I can reproduce the behavior also when SmartSend is off. However, I do not think that this is expected behavior. Executing a command should not modify ("normalize") the contents of a string, which is what is happening here. So to me, this is clearly a bug.
hoechenberger commentedon Jul 16, 2024
I would tend to agree with Clemens Brunner (@cbrnr) here: if I send something to the REPL, it should not get modified. If I intended to print this string, suddenly some intentionally empty lines would be gone -- surely this cannot be right!
anthonykim1 commentedon Jul 26, 2024
Thank you all for your feedback. Let me bring this up the team.
anthonykim1 commentedon Jul 29, 2024
Good news folks. Managed to get this in August plan, so I will be investigating how to best handle this normalization of command when we send it to either terminal REPL or native REPL!
hoechenberger commentedon Jul 29, 2024
Amazing, thanks Anthony Kim (@anthonykim1)!
anthonykim1 commentedon Aug 20, 2024
Hi folks! Just merged in the PR for this, that being said it should be available starting tomorrow's(August 21st) pre-release of the Python extension. Give this a try via running shift+enter on your multi line string or even an assignment to the multi-line string. Thank you all :)
Do not truncate whitespace for multi-line string (microsoft#23977)
anthonykim1 commentedon Aug 26, 2024
Verification steps:
Revert "Do not truncate whitespace for multi-line string" (#24096)
Revert "Do not truncate whitespace for multi-line string" (microsoft#…
Revert "Do not truncate whitespace for multi-line string" (microsoft#…
Revert "Do not truncate whitespace for multi-line string" (#24096) (#…
Do not truncate whitespace for multi-line string (microsoft#23977)
Revert "Do not truncate whitespace for multi-line string" (microsoft#…
github-actions commentedon Oct 12, 2024
Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on, then we will be happy to re-open this issue to pick up where we left off.
Happy Coding!