mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-25 00:46:54 +02:00
properly reset gui state when restarting or coming back from a subprocess
This commit is contained in:
@ -199,7 +199,6 @@ type guiState struct {
|
|||||||
Tags []*commands.Tag
|
Tags []*commands.Tag
|
||||||
MenuItemCount int // can't store the actual list because it's of interface{} type
|
MenuItemCount int // can't store the actual list because it's of interface{} type
|
||||||
PreviousView string
|
PreviousView string
|
||||||
Platform commands.Platform
|
|
||||||
Updating bool
|
Updating bool
|
||||||
Panels *panelStates
|
Panels *panelStates
|
||||||
MainContext string // used to keep the main and secondary views' contexts in sync
|
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
|
FilterPath string // the filename that gets passed to git log
|
||||||
}
|
}
|
||||||
|
|
||||||
// for now the split view will always be on
|
func (gui *Gui) resetState() {
|
||||||
// NewGui builds a new gui handler
|
// we carry over the filter path
|
||||||
func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *commands.OSCommand, tr *i18n.Localizer, config config.AppConfigurer, updater *updates.Updater, filterPath string) (*Gui, error) {
|
prevFilterPath := ""
|
||||||
|
if gui.State != nil {
|
||||||
|
prevFilterPath = gui.State.FilterPath
|
||||||
|
}
|
||||||
|
|
||||||
initialState := &guiState{
|
gui.State = &guiState{
|
||||||
Files: make([]*commands.File, 0),
|
Files: make([]*commands.File, 0),
|
||||||
PreviousView: "files",
|
PreviousView: "files",
|
||||||
Commits: make([]*commands.Commit, 0),
|
Commits: make([]*commands.Commit, 0),
|
||||||
CherryPickedCommits: make([]*commands.Commit, 0),
|
CherryPickedCommits: make([]*commands.Commit, 0),
|
||||||
StashEntries: make([]*commands.StashEntry, 0),
|
StashEntries: make([]*commands.StashEntry, 0),
|
||||||
DiffEntries: make([]*commands.Commit, 0),
|
DiffEntries: make([]*commands.Commit, 0),
|
||||||
Platform: *oSCommand.Platform,
|
|
||||||
Panels: &panelStates{
|
Panels: &panelStates{
|
||||||
Files: &filePanelState{SelectedLine: -1},
|
Files: &filePanelState{SelectedLine: -1},
|
||||||
Branches: &branchPanelState{SelectedLine: 0},
|
Branches: &branchPanelState{SelectedLine: 0},
|
||||||
@ -252,14 +253,17 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *comma
|
|||||||
},
|
},
|
||||||
SideView: nil,
|
SideView: nil,
|
||||||
Ptmx: 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{
|
gui := &Gui{
|
||||||
Log: log,
|
Log: log,
|
||||||
GitCommand: gitCommand,
|
GitCommand: gitCommand,
|
||||||
OSCommand: oSCommand,
|
OSCommand: oSCommand,
|
||||||
State: initialState,
|
|
||||||
Config: config,
|
Config: config,
|
||||||
Tr: tr,
|
Tr: tr,
|
||||||
Updater: updater,
|
Updater: updater,
|
||||||
@ -267,6 +271,9 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *comma
|
|||||||
viewBufferManagerMap: map[string]*tasks.ViewBufferManager{},
|
viewBufferManagerMap: map[string]*tasks.ViewBufferManager{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gui.resetState()
|
||||||
|
gui.State.FilterPath = filterPath
|
||||||
|
|
||||||
gui.watchFilesForChanges()
|
gui.watchFilesForChanges()
|
||||||
|
|
||||||
gui.GenerateSentinelErrors()
|
gui.GenerateSentinelErrors()
|
||||||
|
Reference in New Issue
Block a user