Fix WrapMap::clip_point at the end of a soft-wrapped line

If that's the case and `Bias` is `Left` we clip to the last
character of the soft-wrapped line.

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra
2021-07-21 18:32:32 +02:00
co-authored by Nathan Sobo
parent 915c710f94
commit ef42d14b8c
2 changed files with 18 additions and 1 deletions
+10 -1
View File
@@ -208,7 +208,16 @@ impl Snapshot {
OutputPoint(cursor.sum_start().0 + (point.0 - cursor.seek_start().0))
}
pub fn clip_point(&self, point: OutputPoint, bias: Bias) -> OutputPoint {
pub fn clip_point(&self, mut point: OutputPoint, bias: Bias) -> OutputPoint {
if bias == Bias::Left {
let mut cursor = self.transforms.cursor::<OutputPoint, ()>();
cursor.seek(&point, Bias::Right, &());
let transform = cursor.item().expect("invalid point");
if !transform.is_isomorphic() {
*point.column_mut() -= 1;
}
}
self.to_output_point(self.input.clip_point(self.to_input_point(point), bias))
}
}