crates/editor/src/element.rs 🔗
@@ -9752,11 +9752,39 @@ impl Element for EditorElement {
let mut highlighted_ranges = self
.editor_with_selections(cx)
.map(|editor| {
- editor.read(cx).background_highlights_in_range(
- start_anchor..end_anchor,
- &snapshot.display_snapshot,
- cx.theme(),
- )
+ if editor == self.editor {
+ editor.read(cx).background_highlights_in_range(
+ start_anchor..end_anchor,
+ &snapshot.display_snapshot,
+ cx.theme(),
+ )
+ } else {
+ editor.update(cx, |editor, cx| {
+ let snapshot = editor.snapshot(window, cx);
+ let start_anchor = if start_row == Default::default() {
+ Anchor::min()
+ } else {
+ snapshot.buffer_snapshot().anchor_before(
+ DisplayPoint::new(start_row, 0)
+ .to_offset(&snapshot, Bias::Left),
+ )
+ };
+ let end_anchor = if end_row > max_row {
+ Anchor::max()
+ } else {
+ snapshot.buffer_snapshot().anchor_before(
+ DisplayPoint::new(end_row, 0)
+ .to_offset(&snapshot, Bias::Right),
+ )
+ };
+
+ editor.background_highlights_in_range(
+ start_anchor..end_anchor,
+ &snapshot.display_snapshot,
+ cx.theme(),
+ )
+ })
+ }
})
.unwrap_or_default();