From 47187172b75c373bfa8081e0196771cbc6c22376 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 27 Jul 2021 17:04:26 -0600 Subject: [PATCH] Clip left when moving cursor to end of line This ensures we stay on the same line when the current display line ends with a soft wrap. --- zed/src/editor/movement.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zed/src/editor/movement.rs b/zed/src/editor/movement.rs index dc2f319e334fb6ff4195b5c987ca489c79abd310..0130e6b9e83828e8f43059b7b560423cdc99aa9b 100644 --- a/zed/src/editor/movement.rs +++ b/zed/src/editor/movement.rs @@ -85,7 +85,8 @@ pub fn line_beginning( } pub fn line_end(map: &DisplayMapSnapshot, point: DisplayPoint) -> Result { - 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 {