Skip to content

Commit 5a3cd36

Browse files
fix cursor on wrong line when moved back in wrapped current line
1 parent 92f67a9 commit 5a3cd36

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bpython/curtsiesfrontend/repl.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,8 @@ def paint(self, about_to_exit=False, user_quit=False):
759759

760760
lines = paint.display_linize(self.current_cursor_line+'X', width)
761761
# extra character for space for the cursor
762-
cursor_row = current_line_start_row + len(lines) - 1
762+
current_line_end_row = current_line_start_row + len(lines) - 1
763+
cursor_row = current_line_start_row + (len(self.current_cursor_line) - len(self._current_line) + self.cursor_offset_in_line) / width
763764
if self.stdin.has_focus:
764765
cursor_column = (len(self.current_stdouterr_line) + self.stdin.cursor_offset_in_line) % width
765766
assert cursor_column >= 0, cursor_column
@@ -773,15 +774,15 @@ def paint(self, about_to_exit=False, user_quit=False):
773774
if self.list_win_visible:
774775
logging.debug('infobox display code running')
775776
visible_space_above = history.height
776-
visible_space_below = min_height - cursor_row - 1
777+
visible_space_below = min_height - current_line_end_row - 1
777778

778779
info_max_rows = max(visible_space_above, visible_space_below)
779780
infobox = paint.paint_infobox(info_max_rows, int(width * self.config.cli_suggestion_width), self.matches, self.argspec, self.current_word, self.docstring, self.config)
780781

781782
if visible_space_above >= infobox.height and self.config.curtsies_list_above:
782783
arr[current_line_start_row - infobox.height:current_line_start_row, 0:infobox.width] = infobox
783784
else:
784-
arr[cursor_row + 1:cursor_row + 1 + infobox.height, 0:infobox.width] = infobox
785+
arr[current_line_end_row + 1:current_line_end_row + 1 + infobox.height, 0:infobox.width] = infobox
785786
logging.debug('slamming infobox of shape %r into arr of shape %r', infobox.shape, arr.shape)
786787

787788
logging.debug('about to exit: %r', about_to_exit)

0 commit comments

Comments
 (0)