Fix UI freeze when pressing Down in an empty table

tview's table navigation never terminates when no row is selectable. Turn
selection off while the Downloads panels and the release list are empty.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-20 19:18:24 +02:00
co-authored by Claude Sonnet 5.5
parent 3f6e595719
commit 0b4af81203
3 changed files with 44 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
package ui
import (
"testing"
"time"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
// Pressing Down in an empty table used to loop forever in tview because the
// placeholder row is not selectable.
func TestEmptyTableDownDoesNotHang(t *testing.T) {
tbl := tview.NewTable().SetSelectable(true, false).SetFixed(1, 0)
restoreSelection(tbl, 0, 0, "empty")
screen := tcell.NewSimulationScreen("")
if err := screen.Init(); err != nil {
t.Fatal(err)
}
defer screen.Fini()
screen.SetSize(80, 10)
tbl.SetRect(0, 0, 80, 10)
done := make(chan struct{})
go func() {
tbl.Draw(screen)
tbl.InputHandler()(tcell.NewEventKey(tcell.KeyDown, 0, 0), func(tview.Primitive) {})
tbl.InputHandler()(tcell.NewEventKey(tcell.KeyUp, 0, 0), func(tview.Primitive) {})
tbl.Draw(screen)
close(done)
}()
select {
case <-done:
case <-time.After(2 * time.Second):
t.Fatal("table input handler hung on an empty table")
}
}