Skip to content

Commit

Permalink
Apply row offsets conditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakob Zahn committed May 8, 2024
1 parent aedb3e0 commit 9be5ee5
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/textual/document/_edit.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,16 @@ def do(self, text_area: TextArea, record_selection: bool = True) -> EditResult:
)

row_offset = new_edit_to_row - edit_bottom_row
target_selection_start_row = selection_start_row + row_offset
target_selection_end_row = selection_end_row + row_offset
target_selection_start_row = (
selection_start_row + row_offset
if edit_bottom_row <= selection_start_row
else selection_start_row
)
target_selection_end_row = (
selection_end_row + row_offset
if edit_bottom_row <= selection_end_row
else selection_end_row
)

if self.maintain_selection_offset:
self._updated_selection = Selection(
Expand Down

0 comments on commit 9be5ee5

Please sign in to comment.