Skip to content

Commit

Permalink
Fix display of AI suggestions when the cursor is not on the first line
Browse files Browse the repository at this point in the history
  • Loading branch information
asmeurer committed Oct 11, 2024
1 parent 1e7af58 commit dce5067
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mypython/processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,13 @@ def apply_transformation(self, transformation_input):

source_to_display = transformation_input.source_to_display
column = source_to_display(buffer.document.cursor_position_col)
text_before_cursor = buffer.document.text_before_cursor
current_line_before_cursor = buffer.document.current_line_before_cursor
if buffer.ai_suggestions:
suggestion = buffer.ai_suggestions[buffer.ai_suggestion_index]

terminal_size = app.output.get_size().columns
wrap_width = terminal_size - prompt_width(buffer)
suggestion = replace_newlines_with_spaces(text_before_cursor + suggestion, wrap_width)[column:]
suggestion = replace_newlines_with_spaces(current_line_before_cursor + suggestion, wrap_width)[column:]
else:
suggestion = ""

Expand Down

0 comments on commit dce5067

Please sign in to comment.