Skip to main content

fit

Function fit 

pub fn fit(
    tr: &mut TextRenderer,
    s: &str,
    style: &TextStyle,
    budget: f64,
) -> String
Expand description

Shorten s until it fits budget pixels in style, appending an ellipsis when anything was dropped.

Binary chop on the char index; measure is cheap and the common case (a short label in a wide slot) exits on the first measurement. Returns an empty string when not even one character fits, which is the empty result for a slot that has been squeezed to nothing.

Shared by every history surface: a version name that ellipsises one way in the activity pane and another on the version strip reads as two different names.