From bd014707fd47cd9d0651a9af8c1db6033718a6ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Sun, 11 Oct 2026 00:41:50 -0400 Subject: [PATCH] ChangesList: a long file name ends in an ellipsis before the row's buttons Co-Authored-By: Claude Opus 5.5 (1M context) --- src/git/changes.rs | 12 ++++++++++-- src/git/tests/mod.rs | 1 + src/git/tests/narrow.rs | 39 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 src/git/tests/narrow.rs diff --git a/src/git/changes.rs b/src/git/changes.rs index d96c82d..031635d 100644 --- a/src/git/changes.rs +++ b/src/git/changes.rs @@ -199,12 +199,16 @@ impl ChangesList { .gap_2() .child( div() - .flex_none() + .min_w_0() .text_color(colors.fg) + .debug_selector({ + let path = file.path.clone(); + move || format!("change-name-{path}") + }) .when(file.status == GitStatus::Deleted, |name| { name.line_through() }) - .child(name), + .child(Ellipsis::new(name)), ) .child( div() @@ -218,6 +222,10 @@ impl ChangesList { div() .flex_none() .flex() + .debug_selector({ + let path = file.path.clone(); + move || format!("change-actions-{path}") + }) .child(action( "open", IconName::FileText, diff --git a/src/git/tests/mod.rs b/src/git/tests/mod.rs index 602041f..f54418a 100644 --- a/src/git/tests/mod.rs +++ b/src/git/tests/mod.rs @@ -5,6 +5,7 @@ use gpui::{ use super::DiffViewer; +mod narrow; mod picking; use crate::{forms, primitives::FocusNext, theme::Theme}; diff --git a/src/git/tests/narrow.rs b/src/git/tests/narrow.rs new file mode 100644 index 0000000..52988bd --- /dev/null +++ b/src/git/tests/narrow.rs @@ -0,0 +1,39 @@ +use gpui::{ + Context, IntoElement, ParentElement, Render, TestAppContext, Window, div, prelude::*, px, +}; + +use crate::{lists::GitStatus, theme::Theme}; + +const LONG: &str = "developerID_application_certificate_for_signing.cer"; +const NAME: &str = "change-name-developerID_application_certificate_for_signing.cer"; +const ACTIONS: &str = "change-actions-developerID_application_certificate_for_signing.cer"; + +struct Narrow; + +impl Render for Narrow { + fn render(&mut self, _: &mut Window, _: &mut Context) -> impl IntoElement { + let file = super::super::Changed { + path: LONG.into(), + status: GitStatus::Untracked, + lines: None, + }; + div() + .w(px(260.0)) + .child(super::super::ChangesList::new("narrow", [], []).untracked([file])) + } +} + +/// A long name gives way before the row's buttons; it never runs under them. +#[gpui::test] +fn a_long_name_ends_before_the_buttons(cx: &mut TestAppContext) { + cx.update(Theme::init); + let (_, cx) = cx.add_window_view(|_, _| Narrow); + cx.run_until_parked(); + let name = cx.debug_bounds(NAME).expect("the name"); + let actions = cx.debug_bounds(ACTIONS).expect("the buttons"); + assert!( + name.right() <= actions.left(), + "{name:?} runs into {actions:?}" + ); + assert!(actions.right() <= px(260.0), "{actions:?}"); +}