From 0d1cfe87abe71839caa59995fa6fdde1a3388bac Mon Sep 17 00:00:00 2001 From: Anthony Kim <62267334+anthonykim1@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:40:15 -0800 Subject: [PATCH] Fix backed up command and false exit code (#23025) Resolves: #23016 #22942 --- python_files/pythonrc.py | 4 ++-- python_files/tests/test_shell_integration.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/python_files/pythonrc.py b/python_files/pythonrc.py index 374888ddada5..2edd88874674 100644 --- a/python_files/pythonrc.py +++ b/python_files/pythonrc.py @@ -54,13 +54,13 @@ def __str__(self): result = "" # For non-windows allow recent_command history. if sys.platform != "win32": - result = "{command_finished}{prompt_started}{prompt}{command_start}{command_executed}{command_line}".format( + result = "{command_line}{command_finished}{prompt_started}{prompt}{command_start}{command_executed}".format( + command_line="\x1b]633;E;" + str(get_last_command()) + "\x07", command_finished="\x1b]633;D;" + str(exit_code) + "\x07", prompt_started="\x1b]633;A\x07", prompt=original_ps1, command_start="\x1b]633;B\x07", command_executed="\x1b]633;C\x07", - command_line="\x1b]633;E;" + str(get_last_command()) + "\x07", ) else: result = "{command_finished}{prompt_started}{prompt}{command_start}{command_executed}".format( diff --git a/python_files/tests/test_shell_integration.py b/python_files/tests/test_shell_integration.py index 896df416eced..c5911aad2d1d 100644 --- a/python_files/tests/test_shell_integration.py +++ b/python_files/tests/test_shell_integration.py @@ -13,7 +13,7 @@ def test_decoration_success(): if sys.platform != "win32": assert ( result - == "\x1b]633;D;0\x07\x1b]633;A\x07>>> \x1b]633;B\x07\x1b]633;C\x07\x1b]633;E;None\x07" + == "\x1b]633;E;None\x07\x1b]633;D;0\x07\x1b]633;A\x07>>> \x1b]633;B\x07\x1b]633;C\x07" ) else: pass @@ -28,7 +28,7 @@ def test_decoration_failure(): if sys.platform != "win32": assert ( result - == "\x1b]633;D;1\x07\x1b]633;A\x07>>> \x1b]633;B\x07\x1b]633;C\x07\x1b]633;E;None\x07" + == "\x1b]633;E;None\x07\x1b]633;D;1\x07\x1b]633;A\x07>>> \x1b]633;B\x07\x1b]633;C\x07" ) else: pass