diff options
36 files changed, 215 insertions, 171 deletions
@@ -20,7 +20,7 @@ require ( github.com/imdario/mergo v0.3.11 github.com/integrii/flaggy v1.4.0 github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4 - github.com/jesseduffield/gocui v0.3.1-0.20210402113210-6fd7ef27ce76 + github.com/jesseduffield/gocui v0.3.1-0.20210403045716-a3be78c4ccf6 github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe // indirect github.com/jesseduffield/yaml v2.1.0+incompatible github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 @@ -39,7 +39,7 @@ require ( github.com/stretchr/testify v1.4.0 golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 // indirect golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c // indirect - golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54 // indirect + golang.org/x/sys v0.0.0-20210402192133-700132347e07 // indirect golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 // indirect golang.org/x/text v0.3.6 // indirect ) @@ -96,6 +96,8 @@ github.com/jesseduffield/gocui v0.3.1-0.20210402040718-77a1b9631715 h1:nELTdFJiZ github.com/jesseduffield/gocui v0.3.1-0.20210402040718-77a1b9631715/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg= github.com/jesseduffield/gocui v0.3.1-0.20210402113210-6fd7ef27ce76 h1:miXVlortFNTlOX+KiKW3cVxOR6+Uhl4pnQRei2X26Y4= github.com/jesseduffield/gocui v0.3.1-0.20210402113210-6fd7ef27ce76/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg= +github.com/jesseduffield/gocui v0.3.1-0.20210403045716-a3be78c4ccf6 h1:nENhj0TKu+11RrPm9Ls5YtzkpbNHM0faXr9UECDhODQ= +github.com/jesseduffield/gocui v0.3.1-0.20210403045716-a3be78c4ccf6/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg= github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe h1:qsVhCf2RFyyKIUe/+gJblbCpXMUki9rZrHuEctg6M/E= github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe/go.mod h1:anMibpZtqNxjDbxrcDEAwSdaJ37vyUeM1f/M4uekib4= github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE= @@ -212,6 +214,8 @@ golang.org/x/sys v0.0.0-20210217105451-b926d437f341 h1:2/QtM1mL37YmcsT8HaDNHDgTq golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54 h1:rF3Ohx8DRyl8h2zw9qojyLHLhrJpEMgyPOImREEryf0= golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210402192133-700132347e07 h1:4k6HsQjxj6hVMsI2Vf0yKlzt5lXxZsMW1q0zaq2k8zY= +golang.org/x/sys v0.0.0-20210402192133-700132347e07/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210317153231-de623e64d2a6 h1:EC6+IGYTjPpRfv9a2b/6Puw0W+hLtAhkV1tPsXhutqs= diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 956b67e96..4d0c69a99 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -69,7 +69,7 @@ func (gui *Gui) refreshBranches() { } gui.State.Branches = builder.Build() - if err := gui.postRefreshUpdate(gui.Contexts.Branches); err != nil { + if err := gui.postRefreshUpdate(gui.State.Contexts.Branches); err != nil { gui.Log.Error(err) } @@ -507,8 +507,8 @@ func (gui *Gui) handleNewBranchOffCurrentItem() error { context.GetPanelState().SetSelectedLineIdx(0) } - if context.GetKey() != gui.Contexts.Branches.GetKey() { - if err := gui.pushContext(gui.Contexts.Branches); err != nil { + if context.GetKey() != gui.State.Contexts.Branches.GetKey() { + if err := gui.pushContext(gui.State.Contexts.Branches); err != nil { return err } } diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index 287410ba9..f0223a15e 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -107,7 +107,7 @@ func (gui *Gui) refreshCommitFilesView() error { } gui.State.CommitFileManager.SetFiles(files, to) - return gui.postRefreshUpdate(gui.Contexts.CommitFiles) + return gui.postRefreshUpdate(gui.State.Contexts.CommitFiles) } func (gui *Gui) handleOpenOldCommitFile() error { @@ -167,7 +167,7 @@ func (gui *Gui) handleToggleFileForPatch() error { gui.GitCommand.PatchManager.Reset() } - return gui.postRefreshUpdate(gui.Contexts.CommitFiles) + return gui.postRefreshUpdate(gui.State.Contexts.CommitFiles) } if gui.GitCommand.PatchManager.Active() && gui.GitCommand.PatchManager.To != gui.State.CommitFileManager.GetParent() { @@ -215,7 +215,7 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error { } } - if err := gui.pushContext(gui.Contexts.PatchBuilding); err != nil { + if err := gui.pushContext(gui.State.Contexts.PatchBuilding); err != nil { return err } return gui.handleRefreshPatchBuildingPanel(selectedLineIdx) @@ -231,7 +231,7 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error { return enterTheFile(selectedLineIdx) }, handleClose: func() error { - return gui.pushContext(gui.Contexts.CommitFiles) + return gui.pushContext(gui.State.Contexts.CommitFiles) }, }) } @@ -247,7 +247,7 @@ func (gui *Gui) handleToggleCommitFileDirCollapsed() error { gui.State.CommitFileManager.ToggleCollapsed(node.GetPath()) - if err := gui.postRefreshUpdate(gui.Contexts.CommitFiles); err != nil { + if err := gui.postRefreshUpdate(gui.State.Contexts.CommitFiles); err != nil { gui.Log.Error(err) } @@ -262,14 +262,14 @@ func (gui *Gui) switchToCommitFilesContext(refName string, canRebase bool, conte gui.State.Panels.CommitFiles.SelectedLineIdx = 0 gui.State.Panels.CommitFiles.refName = refName gui.State.Panels.CommitFiles.canRebase = canRebase - gui.Contexts.CommitFiles.SetParentContext(context) - gui.Contexts.CommitFiles.SetWindowName(windowName) + gui.State.Contexts.CommitFiles.SetParentContext(context) + gui.State.Contexts.CommitFiles.SetWindowName(windowName) if err := gui.refreshCommitFilesView(); err != nil { return err } - return gui.pushContext(gui.Contexts.CommitFiles) + return gui.pushContext(gui.State.Contexts.CommitFiles) } // NOTE: this is very similar to handleToggleFileTreeView, could be DRY'd with generics @@ -283,15 +283,15 @@ func (gui *Gui) handleToggleCommitFileTreeView() error { gui.State.CommitFileManager.ExpandToPath(path) index, found := gui.State.CommitFileManager.GetIndexForPath(path) if found { - gui.Contexts.CommitFiles.GetPanelState().SetSelectedLineIdx(index) + gui.State.Contexts.CommitFiles.GetPanelState().SetSelectedLineIdx(index) } } if gui.getCommitFilesView().Context == COMMIT_FILES_CONTEXT_KEY { - if err := gui.Contexts.CommitFiles.HandleRender(); err != nil { + if err := gui.State.Contexts.CommitFiles.HandleRender(); err != nil { return err } - if err := gui.Contexts.CommitFiles.HandleFocus(); err != nil { + if err := gui.State.Contexts.CommitFiles.HandleFocus(); err != nil { return err } } diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 8edcc642d..4da9e1922 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -86,7 +86,7 @@ func (gui *Gui) refreshCommits() error { go utils.Safe(func() { _ = gui.refreshCommitsWithLimit() - context, ok := gui.Contexts.CommitFiles.GetParentContext() + context, ok := gui.State.Contexts.CommitFiles.GetParentContext() if ok && context.GetKey() == BRANCH_COMMITS_CONTEXT_KEY { // This makes sense when we've e.g. just amended a commit, meaning we get a new commit SHA at the same position. // However if we've just added a brand new commit, it pushes the list down by one and so we would end up @@ -127,7 +127,7 @@ func (gui *Gui) refreshCommitsWithLimit() error { } gui.State.Commits = commits - return gui.postRefreshUpdate(gui.Contexts.BranchCommits) + return gui.postRefreshUpdate(gui.State.Contexts.BranchCommits) } func (gui *Gui) refreshRebaseCommits() error { @@ -142,7 +142,7 @@ func (gui *Gui) refreshRebaseCommits() error { } gui.State.Commits = updatedCommits - return gui.postRefreshUpdate(gui.Contexts.BranchCommits) + return gui.postRefreshUpdate(gui.State.Contexts.BranchCommits) } // specific functions @@ -444,7 +444,7 @@ func (gui *Gui) handleViewCommitFiles() error { return nil } - return gui.switchToCommitFilesContext(commit.Sha, true, gui.Contexts.BranchCommits, "commits") + return gui.switchToCommitFilesContext(commit.Sha, true, gui.State.Contexts.BranchCommits, "commits") } func (gui *Gui) handleCreateFixupCommit() error { diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go index c52a32ce3..700fe298a 100644 --- a/pkg/gui/confirmation_panel.go +++ b/pkg/gui/confirmation_panel.go @@ -204,7 +204,7 @@ func (gui *Gui) prepareConfirmationPanel(title, prompt string, hasLoader bool, f } gui.g.Update(func(g *gocui.Gui) error { - return gui.pushContext(gui.Contexts.Confirmation) + return gui.pushContext(gui.State.Contexts.Confirmation) }) return confirmationView, nil } @@ -284,7 +284,7 @@ func (gui *Gui) setKeyBindings(opts createPopupPanelOpts) error { { viewName: "confirmation", key: gui.getKey(keybindingConfig.Universal.TogglePanel), - handler: func() error { return gui.replaceContext(gui.Contexts.Suggestions) }, + handler: func() error { return gui.replaceContext(gui.State.Contexts.Suggestions) }, }, { viewName: "suggestions", @@ -304,7 +304,7 @@ func (gui *Gui) setKeyBindings(opts createPopupPanelOpts) error { { viewName: "suggestions", key: gui.getKey(keybindingConfig.Universal.TogglePanel), - handler: func() error { return gui.replaceContext(gui.Contexts.Confirmation) }, + handler: func() error { return gui.replaceContext(gui.State.Contexts.Confirmation) }, }, } diff --git a/pkg/gui/context.go b/pkg/gui/context.go index 82c89f535..8d2d92cc9 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -92,27 +92,27 @@ type ContextTree struct { func (gui *Gui) allContexts() []Context { return []Context{ - gui.Contexts.Status, - gui.Contexts.Files, - gui.Contexts.Submodules, - gui.Contexts.Branches, - gui.Contexts.Remotes, - gui.Contexts.RemoteBranches, - gui.Contexts.Tags, - gui.Contexts.BranchCommits, - gui.Contexts.CommitFiles, - gui.Contexts.ReflogCommits, - gui.Contexts.Stash, - gui.Contexts.Menu, - gui.Contexts.Confirmation, - gui.Contexts.Credentials, - gui.Contexts.CommitMessage, - gui.Contexts.Normal, - gui.Contexts.Staging, - gui.Contexts.Merging, - gui.Contexts.PatchBuilding, - gui.Contexts.SubCommits, - gui.Contexts.Suggestions, + gui.State.Contexts.Status, + gui.State.Contexts.Files, + gui.State.Contexts.Submodules, + gui.State.Contexts.Branches, + gui.State.Contexts.Remotes, + gui.State.Contexts.RemoteBranches, + gui.State.Contexts.Tags, + gui.State.Contexts.BranchCommits, + gui.State.Contexts.CommitFiles, + gui.State.Contexts.ReflogCommits, + gui.State.Contexts.Stash, + gui.State.Contexts.Menu, + gui.State.Contexts.Confirmation, + gui.State.Contexts.Credentials, + gui.State.Contexts.CommitMessage, + gui.State.Contexts.Normal, + gui.State.Contexts.Staging, + gui.State.Contexts.Merging, + gui.State.Contexts.PatchBuilding, + gui.State.Contexts.SubCommits, + gui.State.Contexts.Suggestions, } } @@ -279,20 +279,20 @@ func (gui *Gui) contextTree() ContextTree { } } -func (gui *Gui) initialViewContextMap() map[string]Context { +func (tree ContextTree) initialViewContextMap() map[string]Context { return map[string]Context{ - "status": gui.Contexts.Status, - "files": gui.Contexts.Files, - "branches": gui.Contexts.Branches, - "commits": gui.Contexts.BranchCommits, - "commitFiles": gui.Contexts.CommitFiles, - "stash": gui.Contexts.Stash, - "menu": gui.Contexts.Menu, - "confirmation": gui.Contexts.Confirmation, - "credentials": gui.Contexts.Credentials, - "commitMessage": gui.Contexts.CommitMessage, - "main": gui.Contexts.Normal, - "secondary": gui.Contexts.Normal, + "status": tree.Status, + "files": tree.Files, + "branches": tree.Branches, + "commits": tree.BranchCommits, + "commitFiles": tree.CommitFiles, + "stash": tree.Stash, + "menu": tree.Menu, + "confirmation": tree.Confirmation, + "credentials": tree.Credentials, + "commitMessage": tree.CommitMessage, + "main": tree.Normal, + "secondary": tree.Normal, } } @@ -307,46 +307,46 @@ func (gui *Gui) popupViewNames() []string { return result } -func (gui *Gui) initialViewTabContextMap() map[string][]tabContext { +func (tree ContextTree) initialViewTabContextMap() map[string][]tabContext { return map[string][]tabContext{ "branches": { { tab: "Local Branches", - contexts: []Context{gui.Contexts.Branches}, + contexts: []Context{tree.Branches}, }, { tab: "Remotes", contexts: []Context{ - gui.Contexts.Remotes, - gui.Contexts.RemoteBranches, + tree.Remotes, + tree.RemoteBranches, }, }, { tab: "Tags", - contexts: []Context{gui.Contexts.Tags}, + contexts: []Context{tree.Tags}, }, }, "commits": { { tab: "Commits", - contexts: []Context{gui.Contexts.BranchCommits}, + contexts: []Context{tree.BranchCommits}, }, { tab: "Reflog", contexts: []Context{ - gui.Contexts.ReflogCommits, + tree.ReflogCommits, }, }, }, "files": { { tab: "Files", - contexts: []Context{gui.Contexts.Files}, + contexts: []Context{tree.Files}, }, { tab: "Submodules", contexts: []Context{ - gui.Contexts.Submodules, + tree.Submodules, }, }, }, @@ -604,9 +604,10 @@ func (gui *Gui) currentSideContext() *ListContext { } func (gui *Gui) defaultSideContext() Context { - return gui.Contexts.Files + return gui.State.Contexts.Files } +// remove the need to do this: always use a mapping func (gui *Gui) setInitialViewContexts() { // arguably we should only have our ViewContextMap and we should do away with // contexts on views, or vice versa @@ -665,7 +666,7 @@ func (gui *Gui) onViewFocusLost(v *gocui.View, newView *gocui.View) error { if v.Name() == "commitFiles" && newView.Name() != "main" && newView.Name() != "secondary" { gui.resetWindowForView("commitFiles") - if err := gui.deactivateContext(gui.Contexts.CommitFiles); err != nil { + if err := gui.deactivateContext(gui.State.Contexts.CommitFiles); err != nil { return err } } diff --git a/pkg/gui/credentials_panel.go b/pkg/gui/credentials_panel.go index 2f2585bcf..3410d3dee 100644 --- a/pkg/gui/credentials_panel.go +++ b/pkg/gui/credentials_panel.go @@ -26,7 +26,7 @@ func (gui *Gui) promptUserForCredential(passOrUname string) string { credentialsView.Mask = '*' } - if err := gui.pushContext(gui.Contexts.Credentials); err != nil { + if err := gui.pushContext(gui.State.Contexts.Credentials); err != nil { return err } diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 5a7ee6c66..2e90818be 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -1,12 +1,6 @@ package gui import ( - - // "io" - // "io/ioutil" - - // "strings" - "fmt" "regexp" "strings" @@ -124,13 +118,13 @@ func (gui *Gui) refreshFilesAndSubmodules() error { } gui.g.Update(func(g *gocui.Gui) error { - if err := gui.postRefreshUpdate(gui.Contexts.Submodules); err != nil { + if err := gui.postRefreshUpdate(gui.State.Contexts.Submodules); err != nil { gui.Log.Error(err) } if gui.getFilesView().Context == FILES_CONTEXT_KEY { // doing this a little custom (as opposed to using gui.postRefreshUpdate) because we handle selecting the file explicitly below - if err := gui.Contexts.Files.HandleRender(); err != nil { + if err := gui.State.Contexts.Files.HandleRender(); err != nil { return err } } @@ -210,7 +204,7 @@ func (gui *Gui) enterFile(forceSecondaryFocused bool, selectedLineIdx int) error if file.HasMergeConflicts { return gui.createErrorPanel(gui.Tr.FileStagingRequirements) } - _ = gui.pushContext(gui.Contexts.Staging) + _ = gui.pushContext(gui.State.Contexts.Staging) return gui.handleRefreshStagingPanel(forceSecondaryFocused, selectedLineIdx) // TODO: check if this is broken, try moving into context code } @@ -412,7 +406,7 @@ func (gui *Gui) handleCommitPress() error { } gui.g.Update(func(g *gocui.Gui) error { - if err := gui.pushContext(gui.Contexts.CommitMessage); err != nil { + if err := gui.pushContext(gui.State.Contexts.CommitMessage); err != nil { return err } @@ -777,7 +771,7 @@ func (gui *Gui) handleSwitchToMerge() error { return gui.createErrorPanel(gui.Tr.FileNoMergeCons) } - return gui.pushContext(gui.Contexts.Merging) + return gui.pushContext(gui.State.Contexts.Merging) } func (gui *Gui) openFile(filename string) error { @@ -842,7 +836,7 @@ func (gui *Gui) handleToggleDirCollapsed() error { gui.State.FileManager.ToggleCollapsed(node.GetPath()) - if err := gui.postRefreshUpdate(gui.Contexts.Files); err != nil { + if err := gui.postRefreshUpdate(gui.State.Contexts.Files); err != nil { gui.Log.Error(err) } @@ -865,10 +859,10 @@ func (gui *Gui) handleToggleFileTreeView() error { } if gui.getFilesView().Context == FILES_CONTEXT_KEY { - if err := gui.Contexts.Files.HandleRender(); err != nil { + if err := gui.State.Contexts.Files.HandleRender(); err != nil { return err } - if err := gui.Contexts.Files.HandleFocus(); err != nil { + if err := gui.State.Contexts.Files.HandleFocus(); err != nil { return err } } diff --git a/pkg/gui/filtering.go b/pkg/gui/filtering.go index b3fa0e089..1f5c5032a 100644 --- a/pkg/gui/filtering.go +++ b/pkg/gui/filtering.go @@ -32,11 +32,11 @@ func (gui *Gui) setFiltering(path string) error { gui.State.ScreenMode = SCREEN_HALF } - if err := gui.pushContext(gui.Contexts.BranchCommits); err != nil { + if err := gui.pushContext(gui.State.Contexts.BranchCommits); err != nil { return err } return gui.refreshSidePanels(refreshOptions{scope: []RefreshableView{COMMITS}, then: func() { - gui.Contexts.BranchCommits.GetPanelState().SetSelectedLineIdx(0) + gui.State.Contexts.BranchCommits.GetPanelState().SetSelectedLineIdx(0) }}) } diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index dd2b38c26..b9d574623 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -64,12 +64,16 @@ type Repo string // Gui wraps the gocui Gui object which handles rendering and events type Gui struct { - g *gocui.Gui - Log *logrus.Entry - GitCommand *commands.GitCommand - OSCommand *oscommands.OSCommand - SubProcess *exec.Cmd - State *guiState + g *gocui.Gui + Log *logrus.Entry + GitCommand *commands.GitCommand + OSCommand *oscommands.OSCommand + + // this is the state of the GUI for the current repo + State *guiState + + // this is a mapping of repos to gui states, so that we can restore the original + // gui state when returning from a subrepo RepoStateMap map[Repo]*guiState Config config.AppConfigurer Tr *i18n.TranslationSet @@ -85,7 +89,6 @@ type Gui struct { // when lazygit is opened outside a git directory we want to open to the most // recent repo with the recent repos popup showing showRecentRepos bool - Contexts ContextTree // this array either includes the events that we're recording in this session // or the events we've recorded in a prior session @@ -101,6 +104,9 @@ type Gui struct { // when you enter into a submodule we'll append the superproject's path to this array // so that you can return to the superproject RepoPathStack []string + + // this tells us whether our views have been initially set up + ViewsSetup bool } type RecordedEvent struct { @@ -317,6 +323,7 @@ type guiState struct { Modes Modes ContextManager ContextManager + Contexts ContextTree ViewContextMap map[string]Context ViewTabContextMap map[string][]tabContext @@ -325,7 +332,9 @@ type guiState struct { // side windows we need to know which view to give focus to for a given window WindowViewNameMap map[string]string - // tells us whether we've set up our views. We only do this once per repo + // tells us whether we've set up our views for the current repo. We'll need to + // do this whenever we switch back and forth between repos to get the views + // back in sync with the repo state ViewsSetup bool } @@ -334,6 +343,7 @@ func (gui *Gui) resetState(filterPath string) { if err == nil { if state := gui.RepoStateMap[Repo(currentDir)]; state != nil { gui.State = state + gui.State.ViewsSetup = false return } } else { @@ -347,6 +357,8 @@ func (gui *Gui) resetState(filterPath string) { screenMode = SCREEN_HALF } + contexts := gui.contextTree() + gui.State = &guiState{ FileManager: filetree.NewFileManager(make([]*models.File, 0), gui.Log, showTree), CommitFileManager: filetree.NewCommitFileManager(make([]*models.CommitFile, 0), gui.Log, showTree), @@ -387,13 +399,15 @@ func (gui *Gui) resetState(filterPath string) { }, Diffing: Diffing{}, }, - ViewContextMap: gui.initialViewContextMap(), - ViewTabContextMap: gui.initialViewTabContextMap(), + ViewContextMap: contexts.initialViewContextMap(), + ViewTabContextMap: contexts.initialViewTabContextMap(), ScreenMode: screenMode, - ContextManager: NewContextManager(gui.Contexts), + // TODO: put contexts in the context manager + ContextManager: NewContextManager(contexts), + Contexts: contexts, } - gui.RepoStateMap[Repo(gui.GitCommand.DotGitDir)] = gui.State + gui.RepoStateMap[Repo(currentDir)] = gui.State } // for now the split view will always be on @@ -414,7 +428,6 @@ func NewGui(log *logrus.Entry, gitCommand *commands.GitCommand, oSCommand *oscom RepoStateMap: map[Repo]*guiState{}, } - gui.Contexts = gui.contextTree() gui.resetState(filterPath) gui.watchFilesForChanges() @@ -472,11 +485,6 @@ func (gui *Gui) Run() error { go utils.Safe(gui.startBackgroundFetch) } - go func() { - gui.Updater.CheckForNewUpdate(gui.onBackgroundUpdateCheckFinish, false) - gui.waitForIntro.Done() - }() - gui.goEvery(time.Second*time.Duration(userConfig.Refresher.RefreshInterval), gui.stopChan, gui.refreshFilesAndSubmodules) g.SetManager(gocui.ManagerFunc(gui.layout), gocui.ManagerFunc(gui.getFocusLayout())) diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 3ebceaa9e..d49151cfb 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -1706,7 +1706,7 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { bindings = append(bindings, &Binding{ViewName: "", Key: rune(i+1) + '0', Modifier: gocui.ModNone, Handler: gui.goToSideWindow(window)}) } - for viewName := range gui.initialViewTabContextMap() { + for viewName := range gui.State.Contexts.initialViewTabContextMap() { bindings = append(bindings, []*Binding{ { ViewName: viewName, @@ -1741,7 +1741,7 @@ func (gui *Gui) keybindings() error { } } - for viewName := range gui.initialViewTabContextMap() { + for viewName := range gui.State.Contexts.initialViewTabContextMap() { viewName := viewName tabClickCallback := func(tabIndex int) error { return gui.onViewT |