From 3ea17248c87409e9935e4a40b928c9d5fc75bb23 Mon Sep 17 00:00:00 2001 From: Hans Date: Sat, 13 Apr 2024 00:36:31 +0800 Subject: [PATCH] Adjust left movement when soft_wrap mode is used (#10464) Release Notes: - Added/Fixed #10350 --- crates/editor/src/movement.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/editor/src/movement.rs b/crates/editor/src/movement.rs index 3758657c5f91aaee8ac661c8f95cc966338d3644..397b33705fbbe7c17813c0e6e4572df69175197f 100644 --- a/crates/editor/src/movement.rs +++ b/crates/editor/src/movement.rs @@ -47,6 +47,12 @@ pub fn left(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint { pub fn saturating_left(map: &DisplaySnapshot, mut point: DisplayPoint) -> DisplayPoint { if point.column() > 0 { *point.column_mut() -= 1; + } else if point.column() == 0 { + // If the current sofr_wrap mode is used, the column corresponding to the display is 0, + // which does not necessarily mean that the actual beginning of a paragraph + if map.display_point_to_fold_point(point, Bias::Left).column() > 0 { + return left(map, point); + } } map.clip_point(point, Bias::Left) }