diff --git a/crates/trawler/src/editor.rs b/crates/trawler/src/editor.rs index fef3870..684fe37 100644 --- a/crates/trawler/src/editor.rs +++ b/crates/trawler/src/editor.rs @@ -166,7 +166,10 @@ pub enum BlockEditorEvent { /// fiction, while local offsets stay true everywhere. Emitted from the /// element's prepaint under exactly the same conditions the native /// request would fire. - RevealCaret { line_top: Pixels, line_height: Pixels }, + RevealCaret { + line_top: Pixels, + line_height: Pixels, + }, } /// One candidate in the reference-completion popup. @@ -1458,7 +1461,8 @@ impl Element for BlockTextElement { if request_autoscroll { // The reveal target: the caret's line, falling back to the // whole element when there's no collapsed caret to target. - let (line_top, line_height_local) = cursor_line_box.unwrap_or((px(0.), bounds.size.height)); + let (line_top, line_height_local) = + cursor_line_box.unwrap_or((px(0.), bounds.size.height)); // With scroll animation enabled, hand the reveal to the owner // to *ease* toward (`RevealCaret`) instead of the list's // native autoscroll, which lands instantly mid-frame. The @@ -1482,10 +1486,7 @@ impl Element for BlockTextElement { // supplies the room at document end). window.request_autoscroll(Bounds::new( point(bounds.left(), bounds.top() + line_top), - size( - bounds.size.width, - line_height_local + px(TYPEAHEAD_MARGIN), - ), + size(bounds.size.width, line_height_local + px(TYPEAHEAD_MARGIN)), )); } } @@ -1759,7 +1760,10 @@ mod caret_glide_tests { } } assert!(converged, "glide never converged: {corners:?}"); - assert_eq!(corners, targets, "convergence must snap exactly onto the target"); + assert_eq!( + corners, targets, + "convergence must snap exactly onto the target" + ); } #[test] diff --git a/crates/trawler/src/main.rs b/crates/trawler/src/main.rs index a453bbb..72caf96 100644 --- a/crates/trawler/src/main.rs +++ b/crates/trawler/src/main.rs @@ -866,9 +866,7 @@ impl TrawlerApp { let moved = (now.item_ix, now.offset_in_item) != (start_offset.item_ix, start_offset.offset_in_item); if moved || !summary_measured { - if let Some(input) = - this.editor.as_ref().map(|e| e.input.clone()) - { + if let Some(input) = this.editor.as_ref().map(|e| e.input.clone()) { input.update(cx, |editor, cx| editor.request_reveal(cx)); } } @@ -973,12 +971,16 @@ impl TrawlerApp { anchor=({}, {:?}) item_bounds={:?} viewport=({:?}..{:?})", target.map(|t| match t { ScrollTarget::Top => "top".to_string(), - ScrollTarget::Offset(o) => format!("top_align({}, {:?})", o.item_ix, o.offset_in_item), - ScrollTarget::RevealBottom { item_ix, .. } => format!("bottom_align({item_ix})"), + ScrollTarget::Offset(o) => + format!("top_align({}, {:?})", o.item_ix, o.offset_in_item), + ScrollTarget::RevealBottom { item_ix, .. } => + format!("bottom_align({item_ix})"), }), self.list_state.logical_scroll_top().item_ix, self.list_state.logical_scroll_top().offset_in_item, - self.list_state.bounds_for_item(item_ix).map(|b| (b.top(), b.bottom())), + self.list_state + .bounds_for_item(item_ix) + .map(|b| (b.top(), b.bottom())), viewport.top(), viewport.bottom(), ); diff --git a/crates/trawler/src/ui_tests.rs b/crates/trawler/src/ui_tests.rs index 3e864ac..b8917ad 100644 --- a/crates/trawler/src/ui_tests.rs +++ b/crates/trawler/src/ui_tests.rs @@ -832,8 +832,7 @@ async fn caret_reveal_eases_instead_of_jumping(cx: &mut gpui::TestAppContext) { .bounds_for_item(focused_ix) .expect("focused row has measured bounds"); assert!( - bounds.bottom() - <= viewport.bottom() - gpui::px(crate::editor::TYPEAHEAD_MARGIN - 20.0) + bounds.bottom() <= viewport.bottom() - gpui::px(crate::editor::TYPEAHEAD_MARGIN - 20.0) && bounds.bottom() >= viewport.bottom() - gpui::px(crate::editor::TYPEAHEAD_MARGIN + 60.0), "eased reveal must land the active line at the typeahead margin: \ @@ -976,8 +975,7 @@ async fn caret_reveal_survives_hot_ticks_across_edits(cx: &mut gpui::TestAppCont .bounds_for_item(focused_ix) .expect("focused row has measured bounds"); assert!( - bounds.bottom() - <= viewport.bottom() - gpui::px(crate::editor::TYPEAHEAD_MARGIN - 20.0) + bounds.bottom() <= viewport.bottom() - gpui::px(crate::editor::TYPEAHEAD_MARGIN - 20.0) && bounds.bottom() >= viewport.bottom() - gpui::px(crate::editor::TYPEAHEAD_MARGIN + 60.0), "hot-tick chain must still land at the typeahead margin: \ @@ -1035,8 +1033,7 @@ async fn caret_reveal_converges_after_large_jumps(cx: &mut gpui::TestAppContext) bounds {bounds:?} viewport {viewport:?}" ); assert!( - bounds.bottom() - <= viewport.bottom() - gpui::px(crate::editor::TYPEAHEAD_MARGIN - 20.0), + bounds.bottom() <= viewport.bottom() - gpui::px(crate::editor::TYPEAHEAD_MARGIN - 20.0), "the reveal chain must land the active line at the typeahead \ margin: bounds {bounds:?} viewport {viewport:?}" ); @@ -1094,8 +1091,7 @@ async fn viewport_follows_focus_past_the_fold(cx: &mut gpui::TestAppContext) { // line must sit well clear of the window's bottom edge — asserted // with slack for the row's own padding. assert!( - bounds.bottom() - <= viewport.bottom() - gpui::px(crate::editor::TYPEAHEAD_MARGIN - 20.0), + bounds.bottom() <= viewport.bottom() - gpui::px(crate::editor::TYPEAHEAD_MARGIN - 20.0), "typeahead margin should keep the active line clear above the \ viewport bottom: bounds {bounds:?} viewport {viewport:?}" );