diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-20 21:05:52 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-07-20 21:05:52 +1000 |
commit | 373f24c80f2a99f7b4e1efd3a4c1f5fdb375e3bf (patch) | |
tree | c3dd353c8809a4cf57cdd1c91a6be933427d0311 /pkg/gui/controllers/helpers/confirmation_helper.go | |
parent | a548b289ef8531d12ba74666a8fcf0aa8dde628f (diff) |
Fix crash on empty menu
When a menu is empty (e.g. due to filtering) we shouldn't crash on focus or selection
Diffstat (limited to 'pkg/gui/controllers/helpers/confirmation_helper.go')
-rw-r--r-- | pkg/gui/controllers/helpers/confirmation_helper.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/pkg/gui/controllers/helpers/confirmation_helper.go b/pkg/gui/controllers/helpers/confirmation_helper.go index c721310b2..fe18dd638 100644 --- a/pkg/gui/controllers/helpers/confirmation_helper.go +++ b/pkg/gui/controllers/helpers/confirmation_helper.go @@ -302,7 +302,12 @@ func (self *ConfirmationHelper) resizeMenu() { _, _ = self.c.GocuiGui().SetView(self.c.Views().Menu.Name(), x0, y0, x1, menuBottom, 0) tooltipTop := menuBottom + 1 - tooltipHeight := getMessageHeight(true, self.c.Contexts().Menu.GetSelected().Tooltip, panelWidth) + 2 // plus 2 for the frame + tooltip := "" + selectedItem := self.c.Contexts().Menu.GetSelected() + if selectedItem != nil { + tooltip = selectedItem.Tooltip + } + tooltipHeight := getMessageHeight(true, tooltip, panelWidth) + 2 // plus 2 for the frame _, _ = self.c.GocuiGui().SetView(self.c.Views().Tooltip.Name(), x0, tooltipTop, x1, tooltipTop+tooltipHeight-1, 0) } |