diff options
author | David Chen <weichen2000121@gmail.com> | 2019-12-08 14:40:11 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-08 14:40:11 -0800 |
commit | 5f21f190b987f2339213e18abdc94bb3402ca2d1 (patch) | |
tree | ae4f82fdd4a3a3640346a042adcafe39e7eea0db /pkg | |
parent | 0d1230a9593f9658bb0d8816e5db3983df873943 (diff) | |
parent | dab78c8a632fa12a24db2247a5c7096c5166c91a (diff) |
Merge branch 'master' into custom-keybindings
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/files_panel.go | 18 | ||||
-rw-r--r-- | pkg/gui/list_view.go | 4 | ||||
-rw-r--r-- | pkg/gui/view_helpers.go | 2 |
3 files changed, 12 insertions, 12 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 5f68f3fab..463db817e 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -27,15 +27,7 @@ func (gui *Gui) getSelectedFile(g *gocui.Gui) (*commands.File, error) { return gui.State.Files[selectedLine], nil } -func (gui *Gui) handleFileSelect(g *gocui.Gui, v *gocui.View) error { - return gui.selectFile(false) -} - func (gui *Gui) selectFile(alreadySelected bool) error { - if _, err := gui.g.SetCurrentView("files"); err != nil { - return err - } - file, err := gui.getSelectedFile(gui.g) if err != nil { if err != gui.Errors.ErrNoFiles { @@ -221,6 +213,14 @@ func (gui *Gui) allFilesStaged() bool { return true } +func (gui *Gui) focusAndSelectFile(g *gocui.Gui, v *gocui.View) error { + if _, err := gui.g.SetCurrentView("files"); err != nil { + return err + } + + return gui.selectFile(false) +} + func (gui *Gui) handleStageAll(g *gocui.Gui, v *gocui.View) error { var err error if gui.allFilesStaged() { @@ -236,7 +236,7 @@ func (gui *Gui) handleStageAll(g *gocui.Gui, v *gocui.View) error { return err } - return gui.handleFileSelect(gui.g, v) + return gui.selectFile(false) } func (gui *Gui) handleIgnoreFile(g *gocui.Gui, v *gocui.View) error { diff --git a/pkg/gui/list_view.go b/pkg/gui/list_view.go index 4d72efc43..274976c4c 100644 --- a/pkg/gui/list_view.go +++ b/pkg/gui/list_view.go @@ -79,8 +79,8 @@ func (gui *Gui) getListViews() []*listView { viewName: "files", getItemsLength: func() int { return len(gui.State.Files) }, getSelectedLineIdxPtr: func() *int { return &gui.State.Panels.Files.SelectedLine }, - handleFocus: gui.wrappedHandler(func() error { return gui.selectFile(true) }), - handleItemSelect: gui.wrappedHandler(func() error { return gui.selectFile(true) }), + handleFocus: gui.focusAndSelectFile, + handleItemSelect: gui.focusAndSelectFile, handleClickSelectedItem: gui.handleFilePress, gui: gui, rendersToMainView: true, diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 6112a5422..bf25dbdbb 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -102,7 +102,7 @@ func (gui *Gui) newLineFocused(g *gocui.Gui, v *gocui.View) error { case "status": return gui.handleStatusSelect(g, v) case "files": - return gui.handleFileSelect(g, v) + return gui.focusAndSelectFile(g, v) case "branches": branchesView := gui.getBranchesView() switch branchesView.Context { |