diff --git a/src/textual/widgets/_text_area.py b/src/textual/widgets/_text_area.py index c4e9a8bbfd..fa66d8a53d 100644 --- a/src/textual/widgets/_text_area.py +++ b/src/textual/widgets/_text_area.py @@ -1396,7 +1396,7 @@ async def _on_key(self, event: events.Key) -> None: # `insert` is not None because event.character cannot be # None because we've checked that it's printable. assert insert is not None - start, end = self.selection + start, end = sorted(self.selection) self._replace_via_keyboard(insert, start, end) def _find_columns_to_next_tab_stop(self) -> int: