Guard empty terminal trees from key events

This commit is contained in:
Brandon McGinty (chatgpt)
2026-08-09 14:23:27 -04:00
committed by Brandon McGinty
parent cbb0fc83c5
commit 214ccb8787
+6
View File
@@ -206,6 +206,9 @@ func (t *Tree) ActiveItem() TreeItem {
}
func (t *Tree) uiKeyEvent(key Key) {
if len(t.lines) == 0 {
return
}
var runHandler = true
switch key {
case KeyArrowUp:
@@ -222,6 +225,9 @@ func (t *Tree) uiKeyEvent(key Key) {
}
func (t *Tree) uiCharacterEvent(ch rune) {
if len(t.lines) == 0 {
return
}
if t.CharacterListener != nil {
t.CharacterListener(t.ui, t, t.lines[t.activeLine].Item, ch)
}