From b2bcdeae1a8bc1432d269d06f7d3a6a37e4bbfc1 Mon Sep 17 00:00:00 2001 From: "R.Eugenio" Date: Tue, 23 Dec 2025 14:31:12 +0100 Subject: [PATCH] fix(virtual_list): Scroll arriba + footer compacto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - moveUp: Calcular screen position para scroll correcto - footer_h: Reducir de 20 a 16 pixels para más filas visibles 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- src/widgets/virtual_list/state.zig | 22 ++++++++++++++++++---- src/widgets/virtual_list/virtual_list.zig | 2 +- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/widgets/virtual_list/state.zig b/src/widgets/virtual_list/state.zig index 325849c..be47ed9 100644 --- a/src/widgets/virtual_list/state.zig +++ b/src/widgets/virtual_list/state.zig @@ -200,16 +200,30 @@ pub const VirtualListState = struct { /// Mueve la selección hacia arriba pub fn moveUp(self: *Self) void { + const window_offset = self.scroll_offset -| self.window_start; + if (self.findSelectedInWindow()) |window_idx| { + // Calcular posición en pantalla actual + const screen_pos = window_idx -| window_offset; + if (window_idx > 0) { + // Hay item anterior en buffer, seleccionarlo self.selectByWindowIndex(window_idx - 1); - } else if (self.window_start > 0) { - // Necesita scroll up - el widget debe manejar esto - self.scroll_offset = if (self.scroll_offset > 0) self.scroll_offset - 1 else 0; + + // Si estábamos en la primera fila visible, hacer scroll + if (screen_pos == 0 and self.scroll_offset > 0) { + self.scroll_offset -= 1; + } + } else { + // Estamos en el inicio del buffer + // Scroll up para cargar más datos (si es posible) + if (self.scroll_offset > 0) { + self.scroll_offset -= 1; + } } } else if (self.current_window.len > 0) { // Sin selección: seleccionar primera fila visible - self.selectByWindowIndex(0); + self.selectByWindowIndex(window_offset); } } diff --git a/src/widgets/virtual_list/virtual_list.zig b/src/widgets/virtual_list/virtual_list.zig index fc1d47c..eaa0d1e 100644 --- a/src/widgets/virtual_list/virtual_list.zig +++ b/src/widgets/virtual_list/virtual_list.zig @@ -116,7 +116,7 @@ pub fn virtualListRect( // Calculate dimensions const header_h: u32 = config.row_height; - const footer_h: u32 = if (config.show_count) 20 else 0; + const footer_h: u32 = if (config.show_count) 16 else 0; // 16px para footer compacto const content_h = bounds.h -| header_h -| footer_h; const visible_rows: usize = @intCast(content_h / config.row_height);