From 83a895a46316a0e29d7ee7adabe76719cc773d63 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 12 Jan 2020 13:39:48 +1100 Subject: [PATCH] reset origin when clicking on list item --- pkg/gui/list_view.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/gui/list_view.go b/pkg/gui/list_view.go index 1c982cfa1..90ea7b8b0 100644 --- a/pkg/gui/list_view.go +++ b/pkg/gui/list_view.go @@ -34,6 +34,7 @@ func (lv *listView) handleLineChange(change int) error { return err } } + view, err := lv.gui.g.View(lv.viewName) if err != nil { return err @@ -56,7 +57,14 @@ func (lv *listView) handleClick(g *gocui.Gui, v *gocui.View) error { *selectedLineIdxPtr = newSelectedLineIdx - if prevSelectedLineIdx == newSelectedLineIdx && lv.gui.currentViewName() == lv.viewName && lv.handleClickSelectedItem != nil { + if lv.rendersToMainView { + if err := lv.gui.resetOrigin(lv.gui.getMainView()); err != nil { + return err + } + } + + prevViewName := lv.gui.currentViewName() + if prevSelectedLineIdx == newSelectedLineIdx && prevViewName == lv.viewName && lv.handleClickSelectedItem != nil { return lv.handleClickSelectedItem(lv.gui.g, v) } return lv.handleItemSelect(lv.gui.g, v)