summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pyrepl/test_reader.py
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-08-26 01:13:36 (GMT)
committerGitHub <noreply@github.com>2024-08-26 01:13:36 (GMT)
commit865bfb1530f377d719cb9d68b4538a19b82922d3 (patch)
treee964f3eb0f5f9a1642d3ae774e3d5db0aedb2eb8 /Lib/test/test_pyrepl/test_reader.py
parent48173655812396500159148c9521dc4dd74782fa (diff)
downloadcpython-865bfb1530f377d719cb9d68b4538a19b82922d3.zip
cpython-865bfb1530f377d719cb9d68b4538a19b82922d3.tar.gz
cpython-865bfb1530f377d719cb9d68b4538a19b82922d3.tar.bz2
[3.13] gh-123177: Fix prompt for wrapped lines in pyrepl (GH-123324) (#123327)
gh-123177: Fix prompt for wrapped lines in pyrepl (GH-123324) When display lines above the cursor come from the cache, the first line to not come from the cache may be a wrapped line, starting half way through a logical line in the buffer. Detect and handle this case to avoid accidentally drawing a stray prompt in the middle of a logical line. (cherry picked from commit 602fcf97df1665538d4e9841f9dc6bc33e38bece) Co-authored-by: Matt Wozniski <mwozniski@bloomberg.net>
Diffstat (limited to 'Lib/test/test_pyrepl/test_reader.py')
-rw-r--r--Lib/test/test_pyrepl/test_reader.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_pyrepl/test_reader.py b/Lib/test/test_pyrepl/test_reader.py
index c09838f..421545e 100644
--- a/Lib/test/test_pyrepl/test_reader.py
+++ b/Lib/test/test_pyrepl/test_reader.py
@@ -31,6 +31,37 @@ class TestReader(TestCase):
reader, _ = handle_events_narrow_console(events)
self.assert_screen_equals(reader, f"{9*"a"}\\\n{9*"a"}\\\naa")
+ def test_calc_screen_prompt_handling(self):
+ def prepare_reader_keep_prompts(*args, **kwargs):
+ reader = prepare_reader(*args, **kwargs)
+ del reader.get_prompt
+ reader.ps1 = ">>> "
+ reader.ps2 = ">>> "
+ reader.ps3 = "... "
+ reader.ps4 = ""
+ reader.can_colorize = False
+ reader.paste_mode = False
+ return reader
+
+ events = code_to_events("if some_condition:\nsome_function()")
+ reader, _ = handle_events_narrow_console(
+ events,
+ prepare_reader=prepare_reader_keep_prompts,
+ )
+ # fmt: off
+ self.assert_screen_equals(
+ reader,
+ (
+ ">>> if so\\\n"
+ "me_condit\\\n"
+ "ion:\n"
+ "... s\\\n"
+ "ome_funct\\\n"
+ "ion()"
+ )
+ )
+ # fmt: on
+
def test_calc_screen_wrap_three_lines_mixed_character(self):
# fmt: off
code = (