Clip left when moving cursor to end of line

Nathan Sobo created

This ensures we stay on the same line when the current display line ends with a soft wrap.

Change summary

zed/src/editor/movement.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Detailed changes

zed/src/editor/movement.rs 🔗

@@ -85,7 +85,8 @@ pub fn line_beginning(
 }
 
 pub fn line_end(map: &DisplayMapSnapshot, point: DisplayPoint) -> Result<DisplayPoint> {
-    Ok(DisplayPoint::new(point.row(), map.line_len(point.row())))
+    let line_end = DisplayPoint::new(point.row(), map.line_len(point.row()));
+    Ok(map.clip_point(line_end, Bias::Left))
 }
 
 pub fn prev_word_boundary(map: &DisplayMapSnapshot, point: DisplayPoint) -> Result<DisplayPoint> {