Checkpoint: Debugging

Agus Zubiaga created

Change summary

crates/editor/src/display_map.rs          |  9 +++++++++
crates/editor/src/display_map/fold_map.rs | 11 +++++++----
crates/editor/src/scroll/autoscroll.rs    | 15 +++++----------
3 files changed, 21 insertions(+), 14 deletions(-)

Detailed changes

crates/editor/src/display_map.rs 🔗

@@ -879,6 +879,15 @@ impl DisplaySnapshot {
         DisplayPoint(block_point)
     }
 
+    pub fn point_to_display_point2(&self, point: MultiBufferPoint, bias: Bias) -> DisplayPoint {
+        let inlay_point = self.inlay_snapshot().to_inlay_point(point);
+        let fold_point = dbg!(self.fold_snapshot().to_fold_point(inlay_point, bias));
+        let tab_point = self.tab_snapshot().to_tab_point(fold_point);
+        let wrap_point = self.wrap_snapshot().tab_point_to_wrap_point(tab_point);
+        let block_point = self.block_snapshot.to_block_point(wrap_point);
+        DisplayPoint(block_point)
+    }
+
     pub fn display_point_to_point(&self, point: DisplayPoint, bias: Bias) -> Point {
         self.inlay_snapshot()
             .to_buffer_point(self.display_point_to_inlay_point(point, bias))

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

@@ -114,8 +114,9 @@ impl FoldPoint {
         let overshoot = self.0 - cursor.start().1.output.lines;
         let mut offset = cursor.start().1.output.len;
         if !overshoot.is_zero() {
-            let transform = cursor.item().expect("display point out of range");
-            assert!(transform.placeholder.is_none());
+            // todo! is this important?
+            // let transform = cursor.item().expect("display point out of range");
+            // assert!(transform.placeholder.is_none());
             let end_inlay_offset = snapshot
                 .inlay_snapshot
                 .to_offset(InlayPoint(cursor.start().1.input.lines + overshoot));
@@ -520,15 +521,17 @@ impl FoldMap {
                         const ELLIPSIS: &str = "⋯";
 
                         let fold_id = fold.id;
+                        let text = " Untitled (1:10) ";
+                        let output = TextSummary::from(text);
                         new_transforms.push(
                             Transform {
                                 summary: TransformSummary {
-                                    output: TextSummary::from(ELLIPSIS),
+                                    output,
                                     input: inlay_snapshot
                                         .text_summary_for_range(fold_range.start..fold_range.end),
                                 },
                                 placeholder: Some(TransformPlaceholder {
-                                    text: ELLIPSIS,
+                                    text: text,
                                     chars: 1,
                                     renderer: ChunkRenderer {
                                         id: ChunkRendererId::Fold(fold.id),

crates/editor/src/scroll/autoscroll.rs 🔗

@@ -157,16 +157,11 @@ impl Editor {
                 .to_display_point(&display_map)
                 .row()
                 .as_f64();
-            target_bottom = dbg!(
-                selections
-                    .last()
-                    .unwrap()
-                    .head()
-                    .to_display_point(&display_map)
-            )
-            .row()
-            .next_row()
-            .as_f64();
+            target_bottom = display_map
+                .point_to_display_point2(selections.last().unwrap().head(), text::Bias::Left)
+                .row()
+                .next_row()
+                .as_f64();
 
             let selections_fit = target_bottom - target_top <= visible_lines;
             if matches!(