Account for trailing below blocks in BlockSnapshot::max_point

Nathan Sobo created

Change summary

crates/editor/src/display_map/block_map.rs | 9 ++++++++-
crates/editor/src/display_map/wrap_map.rs  | 5 -----
2 files changed, 8 insertions(+), 6 deletions(-)

Detailed changes

crates/editor/src/display_map/block_map.rs 🔗

@@ -351,7 +351,14 @@ impl BlockSnapshot {
     }
 
     pub fn max_point(&self) -> BlockPoint {
-        self.to_block_point(self.wrap_snapshot.max_point())
+        let last_transform = self.transforms.last().unwrap();
+        if let Some(block) = &last_transform.block {
+            let row = self.transforms.summary().output_rows - 1;
+            let column = block.text.summary().lines.column;
+            BlockPoint::new(row, column)
+        } else {
+            self.to_block_point(self.wrap_snapshot.max_point())
+        }
     }
 
     pub fn clip_point(&self, point: BlockPoint, bias: Bias) -> BlockPoint {

crates/editor/src/display_map/wrap_map.rs 🔗

@@ -944,11 +944,6 @@ impl WrapPoint {
         Self(super::Point::new(row, column))
     }
 
-    #[cfg(test)]
-    pub fn is_zero(&self) -> bool {
-        self.0.is_zero()
-    }
-
     pub fn row(self) -> u32 {
         self.0.row
     }