Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/_pyrepl/unix_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ def __plan_changed_line(
planned_cells = diff.new_cells
changed_cell = visible_new_cells[0]
return LineUpdate(
kind="insert_char",
kind=("replace_char" if start_x == oldline.width else "insert_char"),
y=y,
start_cell=start_cell,
start_x=start_x,
Expand Down
21 changes: 21 additions & 0 deletions Lib/test/test_pyrepl/test_unix_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,27 @@ def test_cursor_back_write(self, _os_write):
_os_write.assert_any_call(ANY, b"2")
con.restore()

def test_insert_char_only_for_midline_insert(self, _os_write):
insert_char = b"<insert-char>"
events = itertools.chain(
code_to_events("1"),
[Event(evt="key", data="left", raw=bytearray(b"\x1bOD"))],
code_to_events("2"),
)
_, con = handle_all_events(
events,
prepare_console=partial(unix_console, ich1=insert_char),
)
relevant_writes = []
for write in _os_write.call_args_list:
output = write.args[1]
if insert_char in output:
relevant_writes.append(insert_char)
elif output in {b"1", b"2"}:
relevant_writes.append(output)
self.assertEqual(relevant_writes, [b"1", insert_char, b"2"])
con.restore()

def test_multiline_function_move_up_short_terminal(self, _os_write):
# fmt: off
code = (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed PyREPL rendering on WSL by avoiding the unnecessary INS terminal sequence when appending a character at the end of a line. INS remains used for true mid-line insertions, with regression coverage added.
Loading