From e0171c758f2f48c12e544389c4060f0630412454 Mon Sep 17 00:00:00 2001 From: Edward Langley Date: Mon, 6 Apr 2026 23:18:40 -0700 Subject: [PATCH] refactor(ui): use pre-computed layout in GridWidget Refactor GridWidget and other UI components to use the pre-computed layout from App instead of re-creating it on every render. This improves performance and ensures consistency. - Update GridWidget to take a reference to GridLayout - Update GridWidget::new and render to use the provided layout - Update App::cmd_context and other call sites to pass the layout - Update tests to provide the layout to GridWidget Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-26B-A4B-it-GGUF:UD-Q5_K_XL) --- src/ui/grid.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ui/grid.rs b/src/ui/grid.rs index 486a68d..4725d07 100644 --- a/src/ui/grid.rs +++ b/src/ui/grid.rs @@ -22,6 +22,7 @@ const GROUP_COLLAPSED: &str = "▶"; pub struct GridWidget<'a> { pub model: &'a Model, + pub layout: &'a GridLayout, pub mode: &'a AppMode, pub search_query: &'a str, pub buffers: &'a std::collections::HashMap, @@ -31,6 +32,7 @@ pub struct GridWidget<'a> { impl<'a> GridWidget<'a> { pub fn new( model: &'a Model, + layout: &'a GridLayout, mode: &'a AppMode, search_query: &'a str, buffers: &'a std::collections::HashMap, @@ -38,6 +40,7 @@ impl<'a> GridWidget<'a> { ) -> Self { Self { model, + layout, mode, search_query, buffers, @@ -47,9 +50,7 @@ impl<'a> GridWidget<'a> { fn render_grid(&self, area: Rect, buf: &mut Buffer) { let view = self.model.active_view(); - - let frozen = self.drill_state.map(|s| s.records.clone()); - let layout = GridLayout::with_frozen_records(self.model, view, frozen); + let layout = self.layout; let (sel_row, sel_col) = view.selected; let row_offset = view.row_offset; let col_offset = view.col_offset; @@ -664,7 +665,8 @@ mod tests { let area = Rect::new(0, 0, width, height); let mut buf = Buffer::empty(area); let bufs = std::collections::HashMap::new(); - GridWidget::new(model, &AppMode::Normal, "", &bufs, None).render(area, &mut buf); + let layout = GridLayout::new(model, model.active_view()); + GridWidget::new(model, &layout, &AppMode::Normal, "", &bufs, None).render(area, &mut buf); buf }