summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-03-29 10:20:57 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-03-29 11:37:29 +1100
commit76b66ae26f428c58b3b0993d8da4bf31d5933dc7 (patch)
tree603e1633572d3743049667b2952325e032d167db
parenta2790cfe8e6705ebd81c63df2154ec82cb645ae3 (diff)
properly reset gui state when restarting or coming back from a subprocess
-rw-r--r--pkg/gui/gui.go23
1 files changed, 15 insertions, 8 deletions
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index b9ca704bd..70eff9125 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -199,7 +199,6 @@ type guiState struct {
Tags []*commands.Tag
MenuItemCount int // can't store the actual list because it's of interface{} type
PreviousView string
- Platform commands.Platform
Updating bool
Panels *panelStates
MainContext string // used to keep the main and secondary views' contexts in sync
@@ -220,18 +219,20 @@ type guiState struct {
FilterPath string // the filename that gets passed to git log
}
-// for now the split view will always be on
-// NewGui builds a new gui handler
-func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *commands.OSCommand, tr *i18n.Localizer, config config.AppConfigurer, updater *updates.Updater, filterPath string) (*Gui, error) {
+func (gui *Gui) resetState() {
+ // we carry over the filter path
+ prevFilterPath := ""
+ if gui.State != nil {
+ prevFilterPath = gui.State.FilterPath
+ }
- initialState := &guiState{
+ gui.State = &guiState{
Files: make([]*commands.File, 0),
PreviousView: "files",
Commits: make([]*commands.Commit, 0),
CherryPickedCommits: make([]*commands.Commit, 0),
StashEntries: make([]*commands.StashEntry, 0),
DiffEntries: make([]*commands.Commit, 0),
- Platform: *oSCommand.Platform,
Panels: &panelStates{
Files: &filePanelState{SelectedLine: -1},
Branches: &branchPanelState{SelectedLine: 0},
@@ -252,14 +253,17 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *comma
},
SideView: nil,
Ptmx: nil,
- FilterPath: filterPath,
+ FilterPath: prevFilterPath,
}
+}
+// for now the split view will always be on
+// NewGui builds a new gui handler
+func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *commands.OSCommand, tr *i18n.Localizer, config config.AppConfigurer, updater *updates.Updater, filterPath string) (*Gui, error) {
gui := &Gui{
Log: log,
GitCommand: gitCommand,
OSCommand: oSCommand,
- State: initialState,
Config: config,
Tr: tr,
Updater: updater,
@@ -267,6 +271,9 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *comma
viewBufferManagerMap: map[string]*tasks.ViewBufferManager{},
}
+ gui.resetState()
+ gui.State.FilterPath = filterPath
+
gui.watchFilesForChanges()
gui.GenerateSentinelErrors()