Skip to content

Commit 2ce21a0

Browse files
authored
Fix microsoft/vscode#232420: Python REPL cursor drifting (#25521)
It seems `readline` is only imported if `sys.platform != "win32"`, so this fix is applied on that condition too. Context: microsoft/vscode#232420
1 parent 99d5dc2 commit 2ce21a0

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

python_files/pythonrc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def __str__(self):
5252
result = ""
5353
# For non-windows allow recent_command history.
5454
if sys.platform != "win32":
55-
result = "{command_executed}{command_line}{command_finished}{prompt_started}{prompt}{command_start}".format(
55+
result = "{soh}{command_executed}{command_line}{command_finished}{prompt_started}{stx}{prompt}{soh}{command_start}{stx}".format(
56+
soh="\001",
57+
stx="\002",
5658
command_executed="\x1b]633;C\x07",
5759
command_line="\x1b]633;E;" + str(get_last_command()) + "\x07",
5860
command_finished="\x1b]633;D;" + str(exit_code) + "\x07",

python_files/tests/test_shell_integration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_decoration_success():
1717
if sys.platform != "win32" and (not is_wsl):
1818
assert (
1919
result
20-
== "\x1b]633;C\x07\x1b]633;E;None\x07\x1b]633;D;0\x07\x1b]633;A\x07>>> \x1b]633;B\x07"
20+
== "\x01\x1b]633;C\x07\x1b]633;E;None\x07\x1b]633;D;0\x07\x1b]633;A\x07\x02>>> \x01\x1b]633;B\x07\x02"
2121
)
2222
else:
2323
pass
@@ -32,7 +32,7 @@ def test_decoration_failure():
3232
if sys.platform != "win32" and (not is_wsl):
3333
assert (
3434
result
35-
== "\x1b]633;C\x07\x1b]633;E;None\x07\x1b]633;D;1\x07\x1b]633;A\x07>>> \x1b]633;B\x07"
35+
== "\x01\x1b]633;C\x07\x1b]633;E;None\x07\x1b]633;D;1\x07\x1b]633;A\x07\x02>>> \x01\x1b]633;B\x07\x02"
3636
)
3737
else:
3838
pass

0 commit comments

Comments
 (0)