diff --git a/crates/buffer/src/lib.rs b/crates/buffer/src/lib.rs index 0ea8900037..2fbd050bc8 100644 --- a/crates/buffer/src/lib.rs +++ b/crates/buffer/src/lib.rs @@ -570,7 +570,7 @@ impl Buffer { } pub fn clip_point(&self, point: Point, bias: Bias) -> Point { - self.visible_text.clip_point(point, bias) + self.content().clip_point(point, bias) } pub fn clip_offset(&self, offset: usize, bias: Bias) -> usize { @@ -1899,6 +1899,10 @@ impl<'a> Content<'a> { FullOffset(summary.visible + summary.deleted + overshoot) } + pub fn clip_point(&self, point: Point, bias: Bias) -> Point { + self.visible_text.clip_point(point, bias) + } + fn point_for_offset(&self, offset: usize) -> Result { if offset <= self.len() { Ok(self.text_summary_for_range(0..offset).lines) diff --git a/crates/language/src/lib.rs b/crates/language/src/lib.rs index 351d6840b3..57540982d8 100644 --- a/crates/language/src/lib.rs +++ b/crates/language/src/lib.rs @@ -711,7 +711,9 @@ impl Buffer { end = last_edit_new_end + (end - last_edit_old_end); } - Some((start..end, (severity, diagnostic.message))) + let range = + content.clip_point(start, Bias::Left)..content.clip_point(end, Bias::Right); + Some((range, (severity, diagnostic.message))) }), ) };