From 23ba76aa0f9c861b90a10008c8669dff535b56eb Mon Sep 17 00:00:00 2001 From: Anthony Kim <62267334+anthonykim1@users.noreply.github.com> Date: Wed, 11 Sep 2024 19:15:48 -0400 Subject: [PATCH] Revert "Do not truncate whitespace for multi-line string" (#24096) Reverts microsoft/vscode-python#23977 Have to revert https://github.com/microsoft/vscode-python/pull/23977 with issue: https://github.com/microsoft/vscode-python/issues/23743 due to https://github.com/microsoft/vscode-python/issues/24069 Will revisit why https://github.com/microsoft/vscode-python/issues/23743 is breaking if contained inside other top level (in ast term) code block, and look into how to support https://github.com/microsoft/vscode-python/issues/23743 without breaking. --- python_files/normalizeSelection.py | 4 ---- .../terminalExec/sample2_normalized_selection.py | 10 +--------- src/test/python_files/terminalExec/sample2_raw.py | 10 ++-------- 3 files changed, 3 insertions(+), 21 deletions(-) diff --git a/python_files/normalizeSelection.py b/python_files/normalizeSelection.py index 7ea283cc09a6..981251289e57 100644 --- a/python_files/normalizeSelection.py +++ b/python_files/normalizeSelection.py @@ -26,10 +26,6 @@ def _get_statements(selection): This will remove empty newlines around and within the selection, dedent it, and split it using the result of `ast.parse()`. """ - if '"""' in selection or "'''" in selection: - yield selection - return - # Remove blank lines within the selection to prevent the REPL from thinking the block is finished. lines = (line for line in split_lines(selection) if line.strip() != "") diff --git a/src/test/python_files/terminalExec/sample2_normalized_selection.py b/src/test/python_files/terminalExec/sample2_normalized_selection.py index be7b280479c0..a333d4e0daae 100644 --- a/src/test/python_files/terminalExec/sample2_normalized_selection.py +++ b/src/test/python_files/terminalExec/sample2_normalized_selection.py @@ -1,15 +1,7 @@ def add(x, y): - """ - - Adds x - to - y - - - """ + """Adds x to y""" # Some comment return x + y v = add(1, 7) print(v) - diff --git a/src/test/python_files/terminalExec/sample2_raw.py b/src/test/python_files/terminalExec/sample2_raw.py index 230abfda89cb..6ab7e67637f4 100644 --- a/src/test/python_files/terminalExec/sample2_raw.py +++ b/src/test/python_files/terminalExec/sample2_raw.py @@ -1,13 +1,7 @@ def add(x, y): - """ - - Adds x - to - y - - - """ + """Adds x to y""" # Some comment + return x + y v = add(1, 7)