Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Clip left when finding preceding (line) boundary

Antonio Scandurra708852aa0009
diff --git a/crates/editor/src/movement.rs b/crates/editor/src/movement.rs
index 523a0af9640..e589337979b 100644
--- a/crates/editor/src/movement.rs
+++ b/crates/editor/src/movement.rs
@@ -263,13 +263,13 @@ pub fn find_preceding_boundary(
if let Some((prev_ch, prev_point)) = prev {
if is_boundary(ch, prev_ch) {
- return prev_point;
+ return map.clip_point(prev_point, Bias::Left);
}
}
prev = Some((ch, point));
}
- DisplayPoint::zero()
+ map.clip_point(DisplayPoint::zero(), Bias::Left)
}
/// Scans for a boundary preceding the given start point `from` until a boundary is found, indicated by the
@@ -292,7 +292,7 @@ pub fn find_preceding_boundary_in_line(
for (ch, point) in map.reverse_chars_at(from) {
if let Some((prev_ch, prev_point)) = prev {
if is_boundary(ch, prev_ch) {
- return prev_point;
+ return map.clip_point(prev_point, Bias::Left);
}
}
@@ -303,7 +303,7 @@ pub fn find_preceding_boundary_in_line(
prev = Some((ch, point));
}
- prev.map(|(_, point)| point).unwrap_or(from)
+ map.clip_point(prev.map(|(_, point)| point).unwrap_or(from), Bias::Left)
}
/// Scans for a boundary following the given start point until a boundary is found, indicated by the