fix(ui): lay truncating names out at their full width

Moves the gpui fork to 5d366e6, which stops a size measured under
truncation from answering the later whole-text measure. Before it, a
truncating name beside other content in a flex_1 column read as just its
ellipsis with the whole column free. Adds a switcher test that fails
without the fork change.
This commit is contained in:
l0ng-ai
2026-09-27 09:16:55 +08:00
parent fc2dc49309
commit 3269f5dd7d
3 changed files with 79 additions and 25 deletions
Generated
+25 -25
View File
@@ -1527,7 +1527,7 @@ dependencies = [
[[package]]
name = "collections"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"gpui_util",
"indexmap",
@@ -2091,7 +2091,7 @@ dependencies = [
[[package]]
name = "derive_refineable"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"proc-macro2",
"quote",
@@ -3269,7 +3269,7 @@ dependencies = [
[[package]]
name = "gpui"
version = "0.2.2"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"accesskit",
"anyhow",
@@ -3460,7 +3460,7 @@ dependencies = [
[[package]]
name = "gpui_linux"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"accesskit",
"accesskit_unix",
@@ -3511,7 +3511,7 @@ dependencies = [
[[package]]
name = "gpui_macos"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"accesskit",
"accesskit_macos",
@@ -3558,7 +3558,7 @@ dependencies = [
[[package]]
name = "gpui_macros"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"heck 0.5.0",
"proc-macro2",
@@ -3569,7 +3569,7 @@ dependencies = [
[[package]]
name = "gpui_platform"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"console_error_panic_hook",
"gpui",
@@ -3582,7 +3582,7 @@ dependencies = [
[[package]]
name = "gpui_shared_string"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"schemars",
"serde",
@@ -3592,7 +3592,7 @@ dependencies = [
[[package]]
name = "gpui_util"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"anyhow",
"log",
@@ -3601,7 +3601,7 @@ dependencies = [
[[package]]
name = "gpui_web"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"anyhow",
"console_error_panic_hook",
@@ -3625,7 +3625,7 @@ dependencies = [
[[package]]
name = "gpui_wgpu"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"anyhow",
"bytemuck",
@@ -3654,7 +3654,7 @@ dependencies = [
[[package]]
name = "gpui_windows"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"accesskit",
"accesskit_windows",
@@ -3983,7 +3983,7 @@ dependencies = [
[[package]]
name = "http_client"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"anyhow",
"async-compression",
@@ -4008,7 +4008,7 @@ dependencies = [
[[package]]
name = "http_client_tls"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"rustls",
"rustls-platform-verifier",
@@ -5136,7 +5136,7 @@ checksum = "7ebb8d8732c6a6df3d8f032a82911cfc747e00efb95cc46e8d0acd5b5b88570c"
[[package]]
name = "media"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"anyhow",
"bindgen",
@@ -6254,7 +6254,7 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
[[package]]
name = "perf"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"collections",
"serde",
@@ -7257,7 +7257,7 @@ dependencies = [
[[package]]
name = "refineable"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"derive_refineable",
]
@@ -7300,7 +7300,7 @@ checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832"
[[package]]
name = "reqwest_client"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"anyhow",
"bytes",
@@ -7834,7 +7834,7 @@ dependencies = [
[[package]]
name = "scheduler"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"async-task",
"backtrace",
@@ -8677,7 +8677,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "sum_tree"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"heapless",
"log",
@@ -10159,7 +10159,7 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "util"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"anyhow",
"async-fs",
@@ -10198,7 +10198,7 @@ dependencies = [
[[package]]
name = "util_macros"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"perf",
"quote",
@@ -12099,7 +12099,7 @@ dependencies = [
[[package]]
name = "zlog"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"anyhow",
"chrono",
@@ -12144,7 +12144,7 @@ dependencies = [
[[package]]
name = "ztracing"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
dependencies = [
"tracing",
"tracing-subscriber",
@@ -12155,7 +12155,7 @@ dependencies = [
[[package]]
name = "ztracing_macro"
version = "0.1.0"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#ece710e365575bc08656c4a8d20488769b2de9a6"
source = "git+https://github.com/l0ng-ai/zed?branch=tty7#5d366e63171919ea15a972d45acbfc0c6b402c2e"
[[package]]
name = "zune-core"
+7
View File
@@ -402,6 +402,13 @@ codegen-units = 1
# settle exactly at the price of laying out the whole document on the first
# frame (see `ui::diff_overlay::DIFF_LINE_H`).
#
# 5. A text layout remembers the width it was truncated to, and a size measured
# under truncation no longer answers a later measure that asks for the whole
# text. A flex item is measured against a squeezed width first and for its
# content size after; answering the second from the first laid every
# truncating name out as just its ellipsis (see the switcher's
# `a_truncating_name_beside_its_number_takes_the_room_it_has`).
#
# Patching by source rather than editing the `gpui`/`gpui_platform` pins above is
# deliberate: `gpui-component` declares its own `gpui` from the upstream URL, and
# a plain pin swap would put two incompatible copies of gpui in the tree. `[patch]`
+47
View File
@@ -3438,6 +3438,53 @@ fn keycap(label: impl Into<gpui::SharedString>, cx: &App) -> AnyElement {
mod tests {
use super::*;
/// The workspace row's shape: a `flex_1` column, and in it a truncating
/// name sized by its own text beside the slot number. gpui measures that
/// name once against the column's zero basis, and used to answer the
/// content-size measure after it from the same cache — so every name in
/// the list read "…" with the whole column free beside it.
#[gpui::test]
fn a_truncating_name_beside_its_number_takes_the_room_it_has(cx: &mut gpui::TestAppContext) {
use gpui::{AvailableSpace, InteractiveElement as _, point, size};
let vcx = cx.add_empty_window();
vcx.draw(
point(px(0.), px(0.)),
size(
AvailableSpace::Definite(px(LEFT_W)),
AvailableSpace::Definite(px(WS_ROW_H)),
),
|_, _| {
h_flex()
.w(px(LEFT_W))
.gap(px(10.))
.child(div().flex_shrink_0().size(px(WS_AVATAR)))
.child(
v_flex().flex_1().min_w_0().child(
h_flex()
.gap(px(6.))
.min_w_0()
.child(
div()
.min_w_0()
.truncate()
.debug_selector(|| "name".into())
.child("pale-seal"),
)
.child(div().flex_shrink_0().child("1")),
),
)
},
);
let name = vcx.debug_bounds("name").expect("the name was drawn");
// Wider than an ellipsis by a long way: the whole name fits.
assert!(
name.size.width > px(40.),
"the name collapsed to {:?}",
name.size.width
);
}
/// #485 on the path #645 did not cover. A machine the switcher knows only
/// from a listing snapshot has no store entry to name it, so its group
/// used to be labelled by the target's own spelling — and a `Profile`