1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 13:21:38 +03:00

palette: fix min width

This avoids a jarring situation where the width rubber-bands to fit
a run of narrower text when scrolling down through the list of options.

refs: https://github.com/wez/wezterm/issues/1485
This commit is contained in:
Wez Furlong 2023-01-08 07:58:23 -07:00
parent 0c7aeb90c6
commit c9a0537b7b
No known key found for this signature in database
GPG Key ID: 7A7F66A31EC9B387

View File

@ -287,6 +287,18 @@ impl CommandPalette {
);
}
let dimensions = term_window.dimensions;
let size = term_window.terminal_size;
// Avoid covering the entire width
let desired_width = (size.cols / 3).max(75).min(size.cols);
// Center it
let avail_pixel_width =
size.cols as f32 * term_window.render_metrics.cell_size.width as f32;
let desired_pixel_width =
desired_width as f32 * term_window.render_metrics.cell_size.width as f32;
let element = Element::new(&font, ElementContent::Children(elements))
.colors(ElementColors {
border: BorderColor::new(
@ -341,19 +353,8 @@ impl CommandPalette {
height: Dimension::Cells(0.25),
poly: BOTTOM_RIGHT_ROUNDED_CORNER,
},
}));
let dimensions = term_window.dimensions;
let size = term_window.terminal_size;
// Avoid covering the entire width
let desired_width = (size.cols / 3).max(75).min(size.cols);
// Center it
let avail_pixel_width =
size.cols as f32 * term_window.render_metrics.cell_size.width as f32;
let desired_pixel_width =
desired_width as f32 * term_window.render_metrics.cell_size.width as f32;
}))
.min_width(Some(Dimension::Pixels(desired_pixel_width)));
let x_adjust = ((avail_pixel_width - padding_left) - desired_pixel_width) / 2.;