tui: avoid panic when active exec cell area is zero height (#3133)
#### Summary Avoid a potential panic when rendering the active execution cell when the allocated area has zero height. #### Changes - Guard rendering with `active_cell_area.height > 0` and presence of `active_exec_cell`. - Use `saturating_add(1)` for the Y offset to avoid overflow. - Render via `active_exec_cell.as_ref().unwrap().render_ref(...)` after the explicit `is_some` check.
This commit is contained in:
@@ -1371,9 +1371,11 @@ impl WidgetRef for &ChatWidget {
|
||||
fn render_ref(&self, area: Rect, buf: &mut Buffer) {
|
||||
let [active_cell_area, bottom_pane_area] = self.layout_areas(area);
|
||||
(&self.bottom_pane).render(bottom_pane_area, buf);
|
||||
if let Some(cell) = &self.active_exec_cell {
|
||||
if !active_cell_area.is_empty()
|
||||
&& let Some(cell) = &self.active_exec_cell
|
||||
{
|
||||
let mut active_cell_area = active_cell_area;
|
||||
active_cell_area.y += 1;
|
||||
active_cell_area.y = active_cell_area.y.saturating_add(1);
|
||||
active_cell_area.height -= 1;
|
||||
cell.render_ref(active_cell_area, buf);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user