diff --git a/crates/editor/src/movement.rs b/crates/editor/src/movement.rs index 3e5f896564f81a3eea5c3be3152f02a0d7e3b4fe..8685f0709971ac965feac432cbe328c1f2c747fc 100644 --- a/crates/editor/src/movement.rs +++ b/crates/editor/src/movement.rs @@ -69,16 +69,11 @@ pub fn up_by_rows( goal_column = 0; } - let clip_bias = if point.column() == map.line_len(point.row()) { - Bias::Left - } else { - Bias::Right - }; - - ( - map.clip_point(point, clip_bias), - SelectionGoal::Column(goal_column), - ) + let mut clipped_point = map.clip_point(point, Bias::Left); + if clipped_point.row() < point.row() { + clipped_point = map.clip_point(point, Bias::Right); + } + (clipped_point, SelectionGoal::Column(goal_column)) } pub fn down_by_rows( @@ -105,16 +100,11 @@ pub fn down_by_rows( goal_column = map.column_to_chars(point.row(), point.column()) } - let clip_bias = if point.column() == map.line_len(point.row()) { - Bias::Left - } else { - Bias::Right - }; - - ( - map.clip_point(point, clip_bias), - SelectionGoal::Column(goal_column), - ) + let mut clipped_point = map.clip_point(point, Bias::Right); + if clipped_point.row() > point.row() { + clipped_point = map.clip_point(point, Bias::Left); + } + (clipped_point, SelectionGoal::Column(goal_column)) } pub fn line_beginning(