summaryrefslogtreecommitdiffstats
path: root/pkg/gui/gui.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2019-03-11 13:04:08 +1100
committerJesse Duffield <jessedduffield@gmail.com>2019-03-16 10:20:27 +1100
commit4f7f6a073ced1b31be6bbac119d1f0f4de229578 (patch)
tree492d67c4e51b4593c74d26e9a46c434f11c267f7 /pkg/gui/gui.go
parent0e008cc15f8e7cbb6869151d48ae30403bf4dc70 (diff)
allow user to discard old file changes for a given commit
Diffstat (limited to 'pkg/gui/gui.go')
-rw-r--r--pkg/gui/gui.go44
1 files changed, 19 insertions, 25 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index fc40cda07..bd1045105 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -155,11 +155,12 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *comma
StashEntries: make([]*commands.StashEntry, 0),
Platform: *oSCommand.Platform,
Panels: &panelStates{
- Files: &filePanelState{SelectedLine: -1},
- Branches: &branchPanelState{SelectedLine: 0},
- Commits: &commitPanelState{SelectedLine: -1},
- Stash: &stashPanelState{SelectedLine: -1},
- Menu: &menuPanelState{SelectedLine: 0},
+ Files: &filePanelState{SelectedLine: -1},
+ Branches: &branchPanelState{SelectedLine: 0},
+ Commits: &commitPanelState{SelectedLine: -1},
+ CommitFiles: &commitFilesPanelState{SelectedLine: -1},
+ Stash: &stashPanelState{SelectedLine: -1},
+ Menu: &menuPanelState{SelectedLine: 0},
Merging: &mergingPanelState{
ConflictIndex: 0,
ConflictTop: true,
@@ -219,20 +220,21 @@ func max(a, b int) int {
// getFocusLayout returns a manager function for when view gain and lose focus
func (gui *Gui) getFocusLayout() func(g *gocui.Gui) error {
- var focusedView *gocui.View
+ var previousView *gocui.View
return func(g *gocui.Gui) error {
- v := gui.g.CurrentView()
- if v != focusedView {
- if err := gui.onFocusChange(); err != nil {
- return err
- }
- if err := gui.onFocusLost(focusedView); err != nil {
+ newView := gui.g.CurrentView()
+ if err := gui.onFocusChange(); err != nil {
+ return err
+ }
+ // for now we don't consider losing focus to a popup panel as actually losing focus
+ if newView != previousView && !gui.isPopupPanel(newView.Name()) {
+ if err := gui.onFocusLost(previousView, newView); err != nil {
return err
}
- if err := gui.onFocus(v); err != nil {
+ if err := gui.onFocus(newView); err != nil {
return err
}
- focusedView = v
+ previousView = newView
}
return nil
}
@@ -246,31 +248,23 @@ func (gui *Gui) onFocusChange() error {
return gui.setMainTitle()
}
-func (gui *Gui) onFocusLost(v *gocui.View) error {
+func (gui *Gui) onFocusLost(v *gocui.View, newView *gocui.View) error {
if v == nil {
return nil
}
if v.Name() == "branches" {
+ // This stops the branches panel from showing the upstream/downstream changes to the selected branch, when it loses focus
+ // inside renderListPanel it checks to see if the panel has focus
if err := gui.renderListPanel(gui.getBranchesView(), gui.State.Branches); err != nil {
return err
}
} else if v.Name() == "main" {
- // if we have lost focus to a popup panel, that's okay
- if gui.popupPanelFocused() {
- return nil
- }
-
// if we have lost focus to a first-class panel, we need to do some cleanup
if err := gui.changeContext("main", "normal"); err != nil {
return err
}
} else if v.Name() == "commitFiles" {
- // if we have lost focus to a popup panel, that's okay
- if gui.popupPanelFocused() {
- return nil
- }
-
gui.g.SetViewOnBottom(v.Name())
}
gui.Log.Info(v.Name() + " focus lost")