diff --git a/crates/editor/src/display_map/block_map.rs b/crates/editor/src/display_map/block_map.rs index 5aa88a88c4..58ae22403d 100644 --- a/crates/editor/src/display_map/block_map.rs +++ b/crates/editor/src/display_map/block_map.rs @@ -827,8 +827,8 @@ impl AlignedBlock { self.render.lock()(cx) } - pub fn disposition(&self) -> BlockDisposition { - self.block.disposition + pub fn position(&self) -> &Anchor { + &self.block.position } } diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs index b50aa2d9c5..db16b3f01d 100644 --- a/crates/editor/src/element.rs +++ b/crates/editor/src/element.rs @@ -1,4 +1,4 @@ -use crate::display_map::{BlockContext, BlockDisposition}; +use crate::display_map::{BlockContext, ToDisplayPoint}; use super::{ DisplayPoint, Editor, EditorMode, EditorSettings, EditorStyle, Input, Scroll, Select, @@ -19,7 +19,7 @@ use gpui::{ MutableAppContext, PaintContext, Quad, Scene, SizeConstraint, ViewContext, WeakViewHandle, }; use json::json; -use language::Chunk; +use language::{Chunk, ToPoint}; use smallvec::SmallVec; use std::{ cmp::{self, Ordering}, @@ -633,10 +633,11 @@ impl EditorElement { snapshot .blocks_in_range(rows.clone()) .map(|(start_row, block)| { - let anchor_row = match block.disposition() { - BlockDisposition::Above => start_row + block.height(), - BlockDisposition::Below => start_row - 1, - }; + let anchor_row = block + .position() + .to_point(&snapshot.buffer_snapshot) + .to_display_point(snapshot) + .row(); let anchor_x = if rows.contains(&anchor_row) { line_layouts[(anchor_row - rows.start) as usize]