Skip to content

Commit

Permalink
reset filter cursor only when visible, addresses #225
Browse files Browse the repository at this point in the history
  • Loading branch information
wagoodman committed Sep 6, 2019
1 parent d54de94 commit 627e6c5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion ui/filter_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ui

import (
"fmt"

"github.com/jroimartin/gocui"
)

Expand Down
18 changes: 11 additions & 7 deletions ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ func toggleView(g *gocui.Gui, v *gocui.View) (err error) {
func toggleFilterView(g *gocui.Gui, v *gocui.View) error {
// delete all user input from the tree view
Controllers.Filter.view.Clear()
err := Controllers.Filter.view.SetCursor(0, 0)
if err != nil {
return err
}

// toggle hiding
Controllers.Filter.hidden = !Controllers.Filter.hidden
Expand All @@ -104,7 +100,15 @@ func toggleFilterView(g *gocui.Gui, v *gocui.View) error {
Update()
Render()
} else {
return toggleView(g, v)
err := toggleView(g, v)
if err != nil {
return err
}

err = Controllers.Filter.view.SetCursor(0, 0)
if err != nil {
return err
}
}

return nil
Expand Down Expand Up @@ -381,11 +385,11 @@ func Run(analysis *image.AnalysisResult, cache filetree.TreeCache) {
Render()

if err := keyBindings(g); err != nil {
logrus.Error(err)
logrus.Error("keybinding error: ", err)
}

if err := g.MainLoop(); err != nil && err != gocui.ErrQuit {
logrus.Error(err)
logrus.Error("main loop error: ", err)
}
utils.Exit(0)
}

0 comments on commit 627e6c5

Please sign in to comment.