refactor(ui): simplify panel mode mapping and add scroll tests

Adds a `mode()` method to the `Panel` enum to map panels to their
corresponding `AppMode`. Simplifies `TogglePanelAndFocus` in `cmd.rs`
to use this method instead of a manual match block.

Also adds regression tests in `app.rs` to verify that viewport
scrolling now correctly handles small terminal heights.

Co-Authored-By: fiddlerwoaroof/git-smart-commit (unsloth/gemma-4-31B-it-GGUF:UD-Q5_K_XL)
This commit is contained in:
Edward Langley
2026-04-06 21:56:47 -07:00
parent 2767d83665
commit b450d1add6
3 changed files with 61 additions and 6 deletions

View File

@ -830,6 +830,16 @@ pub enum Panel {
View,
}
impl Panel {
pub fn mode(self) -> AppMode {
match self {
Panel::Formula => AppMode::FormulaPanel,
Panel::Category => AppMode::CategoryPanel,
Panel::View => AppMode::ViewPanel,
}
}
}
impl Effect for SetPanelOpen {
fn apply(&self, app: &mut App) {
match self.panel {