Guard empty terminal trees from key events
This commit is contained in:
committed by
Brandon McGinty
parent
cbb0fc83c5
commit
214ccb8787
@@ -206,6 +206,9 @@ func (t *Tree) ActiveItem() TreeItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tree) uiKeyEvent(key Key) {
|
func (t *Tree) uiKeyEvent(key Key) {
|
||||||
|
if len(t.lines) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
var runHandler = true
|
var runHandler = true
|
||||||
switch key {
|
switch key {
|
||||||
case KeyArrowUp:
|
case KeyArrowUp:
|
||||||
@@ -222,6 +225,9 @@ func (t *Tree) uiKeyEvent(key Key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tree) uiCharacterEvent(ch rune) {
|
func (t *Tree) uiCharacterEvent(ch rune) {
|
||||||
|
if len(t.lines) == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
if t.CharacterListener != nil {
|
if t.CharacterListener != nil {
|
||||||
t.CharacterListener(t.ui, t, t.lines[t.activeLine].Item, ch)
|
t.CharacterListener(t.ui, t, t.lines[t.activeLine].Item, ch)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user