Wrap notice plate text
Browse files at this commitdf08a913d183e67446616bbd81fad54103d68b1eParent: d3bace2- fix
- wrap notice plate text
2 changed files +37 -7
crates/app/src/tests/layout.rsmodified+25 -0
| @@ -1930,6 +1930,31 @@ fn the_notice_plate_cannot_reach_the_bench_at_any_height() { | |||
| 1930 | ); | 1930 | ); |
| 1931 | } | 1931 | } |
| 1932 | } | 1932 | } |
| 1933 | +/// The renderer only wraps text when the text measurement receives a definite | ||
| 1934 | +/// width and normal whitespace. This source-level guard keeps both declarations | ||
| 1935 | +/// on the notice plate: `max_w` alone limits max-content after that measurement | ||
| 1936 | +/// and silently permits one-line overflow. It cannot inspect GPUI's painted | ||
| 1937 | +/// lines; only live driving can confirm the full notice actually wrapped. | ||
| 1938 | +#[test] | ||
| 1939 | +fn the_notice_plate_declares_a_bounded_wrapping_text_layout() { | ||
| 1940 | + let stance = src_text("ui/stance.rs"); | ||
| 1941 | + let notice_start = stance.find("fn notice_plate(").expect("notice plate moved or renamed"); | ||
| 1942 | + let notice_end = stance[notice_start..] | ||
| 1943 | + .find("\n/// Thin strip") | ||
| 1944 | + .map(|end| notice_start + end) | ||
| 1945 | + .expect("notice plate no longer precedes the ledger"); | ||
| 1946 | + let plate = &stance[notice_start..notice_end]; | ||
| 1947 | + | ||
| 1948 | + assert!( | ||
| 1949 | + plate.contains(".w_full()") && plate.contains(".max_w(px(480.))"), | ||
| 1950 | + "notice plate lacks a definite width bounded to 480 px; max_w alone does not wrap text" | ||
| 1951 | + ); | ||
| 1952 | + assert!( | ||
| 1953 | + plate.contains(".whitespace_normal()"), | ||
| 1954 | + "notice plate no longer explicitly requests GPUI's wrapping whitespace mode" | ||
| 1955 | + ); | ||
| 1956 | +} | ||
| 1957 | + | ||
| 1933 | 1958 | ||
| 1934 | /// A round trip through the file: what is saved is what the next load reads | 1959 | /// A round trip through the file: what is saved is what the next load reads |
| 1935 | /// back, one seam touched and the other left at its default -- a scratch | 1960 | /// back, one seam touched and the other left at its default -- a scratch |
crates/app/src/ui/stance.rsmodified+12 -7
| @@ -594,14 +594,19 @@ fn notice_plate(message: SharedString, bench_h: f32) -> impl IntoElement { | |||
| 594 | .absolute() | 594 | .absolute() |
| 595 | .bottom(px(notice_bottom_offset(bench_h))) | 595 | .bottom(px(notice_bottom_offset(bench_h))) |
| 596 | .left(px(12.)) | 596 | .left(px(12.)) |
| 597 | - // Wide enough to hold a refusal-plus-remedy sentence in two or three | 597 | + // `max_w` only caps a box after GPUI has measured its text at |
| 598 | - // lines rather than one line cut mid-word: the ledger strip below is | 598 | + // max-content width. `w_full` supplies a definite width to that |
| 599 | - // the one place that must stay a single truncated line (it also | 599 | + // measurement (then `max_w` bounds it at 480 px), and normal |
| 600 | - // carries the project identity, export progress and the timecode on | 600 | + // whitespace gives the text system permission to shape every word |
| 601 | - // the same row), so this plate is the surface with room, and it | 601 | + // into the resulting lines. Keep this a block: as a flex child the |
| 602 | - // takes it. | 602 | + // text's automatic min-content width can overflow its own plate. |
| 603 | + // | ||
| 604 | + // No fixed height: GPUI's shaped lines contribute their actual | ||
| 605 | + // default `phi()` line boxes, so two or three lines grow upward from | ||
| 606 | + // this bottom anchor without reaching down over the bench lanes. | ||
| 607 | + .w_full() | ||
| 603 | .max_w(px(480.)) | 608 | .max_w(px(480.)) |
| 604 | - .flex() | 609 | + .whitespace_normal() |
| 605 | .px(px(10.)) | 610 | .px(px(10.)) |
| 606 | .py(px(6.)) | 611 | .py(px(6.)) |
| 607 | .rounded(px(2.)) | 612 | .rounded(px(2.)) |