@@ -1838,8 +1838,12 @@ def action_cursor_left(self, select: bool = False) -> None:
1838
1838
Args:
1839
1839
select: If True, select the text while moving.
1840
1840
"""
1841
- target = self .get_cursor_left_location ()
1842
- self .move_cursor (target , select = select )
1841
+ if self .selection .is_empty :
1842
+ target = self .get_cursor_left_location ()
1843
+ self .move_cursor (target , select = select )
1844
+ else :
1845
+ start , end = self .selection
1846
+ self .move_cursor (min (start , end ), select = select )
1843
1847
1844
1848
def get_cursor_left_location (self ) -> Location :
1845
1849
"""Get the location the cursor will move to if it moves left.
@@ -1857,8 +1861,12 @@ def action_cursor_right(self, select: bool = False) -> None:
1857
1861
Args:
1858
1862
select: If True, select the text while moving.
1859
1863
"""
1860
- target = self .get_cursor_right_location ()
1861
- self .move_cursor (target , select = select )
1864
+ if self .selection .is_empty :
1865
+ target = self .get_cursor_right_location ()
1866
+ self .move_cursor (target , select = select )
1867
+ else :
1868
+ start , end = self .selection
1869
+ self .move_cursor (max (start , end ), select = select )
1862
1870
1863
1871
def get_cursor_right_location (self ) -> Location :
1864
1872
"""Get the location the cursor will move to if it moves right.
0 commit comments