Skip to content

SmartSend removes empty lines with triple-quoted strings #23743

Closed as not planned

Description

@cbrnr

Type: Bug

Behaviour

SmartSend on a triple-quoted string containing empty lines (i.e. two or more subsequent \n) removes empty lines on execution.

Steps to reproduce:

  1. Hit Shift-Enter on the following string:
"""Hello

World




How 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:

Activity

  1. added
    triage-needed
    on Jul 4, 2024
  2. anthonykim1 commented on Jul 15, 2024

    @anthonykim1

    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.

  3. added and removed
    triage-needed
    on Jul 15, 2024
  4. added
    info-needed
    on Jul 15, 2024
  5. cbrnr commented on Jul 16, 2024

    @cbrnr
    Author

    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.

  6. hoechenberger commented on Jul 16, 2024

    @hoechenberger

    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!

  7. anthonykim1 commented on Jul 26, 2024

    @anthonykim1

    Thank you all for your feedback. Let me bring this up the team.

  8. anthonykim1 commented on Jul 29, 2024

    @anthonykim1

    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!

  9. hoechenberger commented on Jul 29, 2024

    @hoechenberger
  10. anthonykim1 commented on Aug 20, 2024

    @anthonykim1

    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 :)

  11. added
    verification-needed
    on Aug 26, 2024
  12. anthonykim1 commented on Aug 26, 2024

    @anthonykim1

    Verification steps:

    1. Install latest pre-release version of Python extension
    2. Open a Python file or create one with multi line string such as
    """
    hello there
    
    
    
    """
    
    1. Press shift+enter and watch that new line character inside the multi-line string are NOT truncated and therefore respected.
  13. added
    triage-needed
    on Sep 11, 2024
  14. github-actions commented on Oct 12, 2024

    @github-actions

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-replinfo-neededtriage-neededverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions