fix: panic when invoking delete on empty tui (#2584)

If the result set is empty and thus the TUI does not show any entries,
a panic occurs when a user invokes 'delete' via Prefix Ctrl-D or Ctrl-D
in the inspector..
This commit is contained in:
Helmut K. C. Tessarek
2025-02-19 06:01:03 +01:00
committed by GitHub
parent e2f10db3f0
commit c55ea10a4b

View File

@@ -1116,6 +1116,9 @@ pub async fn history(
match app.handle_input(settings, &event::read()?, &mut std::io::stdout())? { match app.handle_input(settings, &event::read()?, &mut std::io::stdout())? {
InputAction::Continue => {}, InputAction::Continue => {},
InputAction::Delete(index) => { InputAction::Delete(index) => {
if results.is_empty() {
break;
}
app.results_len -= 1; app.results_len -= 1;
let selected = app.results_state.selected(); let selected = app.results_state.selected();
if selected == app.results_len { if selected == app.results_len {