T24c round 1 fix

- FileChangeCard's header wraps: the path keeps label_width, counts and
  verdict drop below as one group; MultiFileDiffReview's header wraps its
  counts and its all-buttons inside the box, parted by justify_between
- git::DiffViewer's fold rows are Tab stops with a focus ring when the
  owner opens folds; every row keeps a transparent border so heights match;
  an inert fold no longer shows a pointer
- tests: a_narrow_review_wraps_its_rows_inside_its_box,
  git::a_fold_opens_from_the_keyboard; the gallery adds a 280px review
- AGENTS: taffy drops gaps beside an auto margin; wrapping headers
This commit is contained in:
ZacharyZhang-NY committed 2026-09-26 08:52:38 -04:00
1 parent 0a44a2d905
commit b9bff970d0
8 files changed
+172 -28

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
use gpui::{
Context, IntoElement, KeyBinding, KeyUpEvent, Keystroke, ParentElement, Render, Styled,
TestAppContext, VisualTestContext, Window, div, px,
};
use super::DiffViewer;
use crate::{forms, primitives::FocusNext, theme::Theme};
/// A diff whose first stretch folds, and the folds asked open.
struct Folded {
opened: Vec<usize>,
}
impl Render for Folded {
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
let view = cx.entity();
let old: String = (0..20).map(|ix| format!("line {ix}\n")).collect();
let new = old.replace("line 18", "line eighteen");
div().w(px(480.0)).h(px(320.0)).child(
DiffViewer::new("diff", "a.rs", &old, &new)
.headless()
.on_open(move |ix, _, cx| view.update(cx, |folded, _| folded.opened.push(ix))),
)
}
}
fn settle(cx: &mut VisualTestContext) {
cx.run_until_parked();
cx.update(|window, _| window.refresh());
cx.run_until_parked();
}
#[gpui::test]
fn a_fold_opens_from_the_keyboard(cx: &mut TestAppContext) {
cx.update(|cx| {
Theme::init(cx);
forms::bind_keys(cx);
cx.bind_keys([KeyBinding::new("tab", FocusNext, None)]);
});
let (view, cx) = cx.add_window_view(|_, _| Folded { opened: Vec::new() });
cx.update(|window, _| window.activate_window());
settle(cx);
cx.update(|window, _| window.focus_next());
settle(cx);
cx.simulate_keystrokes("enter");
settle(cx);
cx.simulate_event(KeyUpEvent {
keystroke: Keystroke::parse("enter").expect("a key"),
});
settle(cx);
assert_eq!(view.read_with(cx, |folded, _| folded.opened.clone()), [0]);
}