fix: prevent crash when splits are resized too small
This commit is contained in:
parent
661d30b567
commit
9ed56eb2db
2 changed files with 34 additions and 3 deletions
|
|
@ -437,8 +437,12 @@ impl Terminal {
|
|||
if width != self.size.width || height != self.size.height {
|
||||
let instant = Instant::now();
|
||||
|
||||
self.size.width = width;
|
||||
self.size.height = height;
|
||||
// Clamp dimensions to ensure at least 1 row and 1 column,
|
||||
// preventing index-out-of-bounds panics in alacritty_terminal.
|
||||
let min_width = self.size.cell_width.ceil() as u32;
|
||||
let min_height = self.size.cell_height.ceil() as u32;
|
||||
self.size.width = width.max(min_width);
|
||||
self.size.height = height.max(min_height);
|
||||
|
||||
self.notifier.on_resize(self.size.into());
|
||||
self.term.lock().resize(self.size);
|
||||
|
|
|
|||
|
|
@ -386,7 +386,34 @@ where
|
|||
- self.padding.y() as i32;
|
||||
|
||||
if view_w <= 0 || view_h <= 0 {
|
||||
// Zero sized image
|
||||
// Pane too small for content, but still fill background
|
||||
let terminal = self.terminal.lock().unwrap();
|
||||
let meta = &terminal.metadata_set[terminal.default_attrs().metadata];
|
||||
let background_color = shade(meta.bg, state.is_focused && !self.disabled);
|
||||
renderer.fill_quad(
|
||||
Quad {
|
||||
bounds: layout.bounds(),
|
||||
border: Border {
|
||||
radius: if self.show_headerbar {
|
||||
[0.0, 0.0, corner_radius[2], corner_radius[3]].into()
|
||||
} else {
|
||||
corner_radius.into()
|
||||
},
|
||||
width: self.border.width,
|
||||
color: self.border.color,
|
||||
},
|
||||
..Default::default()
|
||||
},
|
||||
Color::from_rgba(
|
||||
f32::from(background_color.r()) / 255.0,
|
||||
f32::from(background_color.g()) / 255.0,
|
||||
f32::from(background_color.b()) / 255.0,
|
||||
match self.opacity {
|
||||
Some(opacity) => opacity,
|
||||
None => f32::from(background_color.a()) / 255.0,
|
||||
},
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue