mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-11-24 08:52:21 +02:00
refactor
This commit is contained in:
parent
fafd5234bd
commit
0898a7bb57
4
go.mod
4
go.mod
@ -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
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@ -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=
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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) },
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
}})
|
||||
}
|
||||
|
@ -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()))
|
||||
|
@ -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.onViewTabClick(viewName, tabIndex) }
|
||||
|
||||
|
@ -152,7 +152,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
||||
branchesView.ContainsList = true
|
||||
}
|
||||
|
||||
commitFilesView, err := setViewFromDimensions("commitFiles", gui.Contexts.CommitFiles.GetWindowName(), true)
|
||||
commitFilesView, err := setViewFromDimensions("commitFiles", gui.State.Contexts.CommitFiles.GetWindowName(), true)
|
||||
if err != nil {
|
||||
if err.Error() != UNKNOWN_VIEW_ERROR_MSG {
|
||||
return err
|
||||
@ -266,23 +266,20 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
||||
gui.State.OldInformation = informationStr
|
||||
}
|
||||
|
||||
if !gui.State.ViewsSetup {
|
||||
if !gui.ViewsSetup {
|
||||
if err := gui.onInitialViewsCreation(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gui.State.ViewsSetup = true
|
||||
gui.ViewsSetup = true
|
||||
}
|
||||
|
||||
if gui.g.CurrentView() == nil {
|
||||
initialContext := gui.Contexts.Files
|
||||
if gui.State.Modes.Filtering.Active() {
|
||||
initialContext = gui.Contexts.BranchCommits
|
||||
}
|
||||
|
||||
if err := gui.pushContext(initialContext); err != nil {
|
||||
if !gui.State.ViewsSetup {
|
||||
if err := gui.onInitialViewsCreationForRepo(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gui.State.ViewsSetup = true
|
||||
}
|
||||
|
||||
for _, listContext := range gui.getListContexts() {
|
||||
@ -323,7 +320,7 @@ func (gui *Gui) layout(g *gocui.Gui) error {
|
||||
return gui.resizeCurrentPopupPanel()
|
||||
}
|
||||
|
||||
func (gui *Gui) onInitialViewsCreation() error {
|
||||
func (gui *Gui) onInitialViewsCreationForRepo() error {
|
||||
gui.setInitialViewContexts()
|
||||
|
||||
// hide any popup views. This only applies when we've just switched repos
|
||||
@ -331,6 +328,28 @@ func (gui *Gui) onInitialViewsCreation() error {
|
||||
_, _ = gui.g.SetViewOnBottom(viewName)
|
||||
}
|
||||
|
||||
// the status panel is not actually a list context at the moment, so it is excluded
|
||||
// here. Arguably that's quite convenient because it means we're back to starting
|
||||
// in the files panel when landing in a new repo, but when returning from a submodule
|
||||
// we'll be back in the submodules context. This still seems awkward though, and it's
|
||||
// definitely going to break when (if) we make the status context a list context
|
||||
initialContext := gui.currentSideContext()
|
||||
if initialContext == nil {
|
||||
if gui.State.Modes.Filtering.Active() {
|
||||
initialContext = gui.State.Contexts.BranchCommits
|
||||
} else {
|
||||
initialContext = gui.State.Contexts.Files
|
||||
}
|
||||
}
|
||||
|
||||
if err := gui.pushContext(initialContext); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return gui.loadNewRepo()
|
||||
}
|
||||
|
||||
func (gui *Gui) onInitialViewsCreation() error {
|
||||
gui.g.Mutexes.ViewsMutex.Lock()
|
||||
// add tabs to views
|
||||
for _, view := range gui.g.Views() {
|
||||
@ -342,10 +361,6 @@ func (gui *Gui) onInitialViewsCreation() error {
|
||||
}
|
||||
gui.g.Mutexes.ViewsMutex.Unlock()
|
||||
|
||||
if err := gui.pushContext(gui.defaultSideContext()); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := gui.keybindings(); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -357,5 +372,9 @@ func (gui *Gui) onInitialViewsCreation() error {
|
||||
gui.showRecentRepos = false
|
||||
}
|
||||
|
||||
return gui.loadNewRepo()
|
||||
gui.Updater.CheckForNewUpdate(gui.onBackgroundUpdateCheckFinish, false)
|
||||
|
||||
gui.waitForIntro.Done()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ func (gui *Gui) refreshMainViewForLineByLine(state *lBlPanelState) error {
|
||||
var includedLineIndices []int
|
||||
// I'd prefer not to have knowledge of contexts using this file but I'm not sure
|
||||
// how to get around this
|
||||
if gui.currentContext().GetKey() == gui.Contexts.PatchBuilding.GetKey() {
|
||||
if gui.currentContext().GetKey() == gui.State.Contexts.PatchBuilding.GetKey() {
|
||||
filename := gui.getSelectedCommitFileName()
|
||||
var err error
|
||||
includedLineIndices, err = gui.GitCommand.PatchManager.GetFileIncLineIndices(filename)
|
||||
@ -341,9 +341,9 @@ func (gui *Gui) handleOpenFileAtLine() error {
|
||||
// again, would be good to use inheritance here (or maybe even composition)
|
||||
var filename string
|
||||
switch gui.State.MainContext {
|
||||
case gui.Contexts.PatchBuilding.GetKey():
|
||||
case gui.State.Contexts.PatchBuilding.GetKey():
|
||||
filename = gui.getSelectedCommitFileName()
|
||||
case gui.Contexts.Staging.GetKey():
|
||||
case gui.State.Contexts.Staging.GetKey():
|
||||
file := gui.getSelectedFile()
|
||||
if file == nil {
|
||||
return nil
|
||||
|
@ -530,20 +530,20 @@ func (gui *Gui) suggestionsListContext() *ListContext {
|
||||
|
||||
func (gui *Gui) getListContexts() []*ListContext {
|
||||
return []*ListContext{
|
||||
gui.Contexts.Menu,
|
||||
gui.Contexts.Files,
|
||||
gui.Contexts.Branches,
|
||||
gui.Contexts.Remotes,
|
||||
gui.Contexts.RemoteBranches,
|
||||
gui.Contexts.Tags,
|
||||
gui.Contexts.BranchCommits,
|
||||
gui.Contexts.BranchCommits,
|
||||
gui.Contexts.ReflogCommits,
|
||||
gui.Contexts.SubCommits,
|
||||
gui.Contexts.Stash,
|
||||
gui.Contexts.CommitFiles,
|
||||
gui.Contexts.Submodules,
|
||||
gui.Contexts.Suggestions,
|
||||
gui.State.Contexts.Menu,
|
||||
gui.State.Contexts.Files,
|
||||
gui.State.Contexts.Branches,
|
||||
gui.State.Contexts.Remotes,
|
||||
gui.State.Contexts.RemoteBranches,
|
||||
gui.State.Contexts.Tags,
|
||||
gui.State.Contexts.BranchCommits,
|
||||
gui.State.Contexts.BranchCommits,
|
||||
gui.State.Contexts.ReflogCommits,
|
||||
gui.State.Contexts.SubCommits,
|
||||
gui.State.Contexts.Stash,
|
||||
gui.State.Contexts.CommitFiles,
|
||||
gui.State.Contexts.Submodules,
|
||||
gui.State.Contexts.Suggestions,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -107,6 +107,8 @@ func (t *runFunctionTask) GetKind() TaskKind {
|
||||
// }
|
||||
|
||||
func (gui *Gui) runTaskForView(viewName string, task updateTask) error {
|
||||
gui.Log.Warn("running new task for view")
|
||||
|
||||
switch task.GetKind() {
|
||||
case RENDER_STRING:
|
||||
specificTask := task.(*renderStringTask)
|
||||
|
@ -88,7 +88,7 @@ func (gui *Gui) createMenu(title string, items []*menuItem, createMenuOptions cr
|
||||
gui.State.Panels.Menu.SelectedLineIdx = 0
|
||||
|
||||
gui.g.Update(func(g *gocui.Gui) error {
|
||||
return gui.pushContext(gui.Contexts.Menu)
|
||||
return gui.pushContext(gui.State.Contexts.Menu)
|
||||
})
|
||||
return nil
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ func (gui *Gui) handleEscapeMerge() error {
|
||||
// it's possible this method won't be called from the merging view so we need to
|
||||
// ensure we only 'return' focus if we already have it
|
||||
if gui.g.CurrentView() == gui.getMainView() {
|
||||
return gui.pushContext(gui.Contexts.Files)
|
||||
return gui.pushContext(gui.State.Contexts.Files)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -303,14 +303,14 @@ func (gui *Gui) promptToContinueRebase() error {
|
||||
prompt: gui.Tr.ConflictsResolved,
|
||||
handlersManageFocus: true,
|
||||
handleConfirm: func() error {
|
||||
if err := gui.pushContext(gui.Contexts.Files); err != nil {
|
||||
if err := gui.pushContext(gui.State.Contexts.Files); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return gui.genericMergeCommand("continue")
|
||||
},
|
||||
handleClose: func() error {
|
||||
return gui.pushContext(gui.Contexts.Files)
|
||||
return gui.pushContext(gui.State.Contexts.Files)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -109,8 +109,8 @@ func (gui *Gui) handleEscapePatchBuildingPanel() error {
|
||||
gui.GitCommand.PatchManager.Reset()
|
||||
}
|
||||
|
||||
if gui.currentContext().GetKey() == gui.Contexts.PatchBuilding.GetKey() {
|
||||
return gui.pushContext(gui.Contexts.CommitFiles)
|
||||
if gui.currentContext().GetKey() == gui.State.Contexts.PatchBuilding.GetKey() {
|
||||
return gui.pushContext(gui.State.Contexts.CommitFiles)
|
||||
} else {
|
||||
// need to re-focus in case the secondary view should now be hidden
|
||||
return gui.currentContext().HandleFocus()
|
||||
|
@ -42,7 +42,7 @@ func (gui *Gui) handleCreatePatchOptionsMenu() error {
|
||||
},
|
||||
}...)
|
||||
|
||||
if gui.currentContext().GetKey() == gui.Contexts.BranchCommits.GetKey() {
|
||||
if gui.currentContext().GetKey() == gui.State.Contexts.BranchCommits.GetKey() {
|
||||
selectedCommit := gui.getSelectedLocalCommit()
|
||||
if selectedCommit != nil && gui.GitCommand.PatchManager.To != selectedCommit.Sha {
|
||||
// adding this option to index 1
|
||||
@ -179,7 +179,7 @@ func (gui *Gui) handleApplyPatch(reverse bool) error {
|
||||
func (gui *Gui) handleResetPatch() error {
|
||||
gui.GitCommand.PatchManager.Reset()
|
||||
if gui.currentContextKeyIgnoringPopups() == MAIN_PATCH_BUILDING_CONTEXT_KEY {
|
||||
if err := gui.pushContext(gui.Contexts.CommitFiles); err != nil {
|
||||
if err := gui.pushContext(gui.State.Contexts.CommitFiles); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ func (gui *Gui) handleGenericMergeCommandResult(result error) error {
|
||||
prompt: gui.Tr.FoundConflicts,
|
||||
handlersManageFocus: true,
|
||||
handleConfirm: func() error {
|
||||
return gui.pushContext(gui.Contexts.Files)
|
||||
return gui.pushContext(gui.State.Contexts.Files)
|
||||
},
|
||||
handleClose: func() error {
|
||||
if err := gui.returnFromContext(); err != nil {
|
||||
|
@ -79,7 +79,7 @@ func (gui *Gui) refreshReflogCommits() error {
|
||||
state.FilteredReflogCommits = state.ReflogCommits
|
||||
}
|
||||
|
||||
return gui.postRefreshUpdate(gui.Contexts.ReflogCommits)
|
||||
return gui.postRefreshUpdate(gui.State.Contexts.ReflogCommits)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleCheckoutReflogCommit() error {
|
||||
@ -116,5 +116,5 @@ func (gui *Gui) handleViewReflogCommitFiles() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
return gui.switchToCommitFilesContext(commit.Sha, false, gui.Contexts.ReflogCommits, "commits")
|
||||
return gui.switchToCommitFilesContext(commit.Sha, false, gui.State.Contexts.ReflogCommits, "commits")
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ func (gui *Gui) handleRemoteBranchSelect() error {
|
||||
}
|
||||
|
||||
func (gui *Gui) handleRemoteBranchesEscape() error {
|
||||
return gui.pushContext(gui.Contexts.Remotes)
|
||||
return gui.pushContext(gui.State.Contexts.Remotes)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleMergeRemoteBranch() error {
|
||||
|
@ -80,7 +80,7 @@ func (gui *Gui) handleRemoteEnter() error {
|
||||
}
|
||||
gui.State.Panels.RemoteBranches.SelectedLineIdx = newSelectedLine
|
||||
|
||||
return gui.pushContext(gui.Contexts.RemoteBranches)
|
||||
return gui.pushContext(gui.State.Contexts.RemoteBranches)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleAddRemote() error {
|
||||
|
@ -17,7 +17,7 @@ func (gui *Gui) resetToRef(ref string, strength string, options oscommands.RunCo
|
||||
// loading a heap of commits is slow so we limit them whenever doing a reset
|
||||
gui.State.Panels.Commits.LimitCommits = true
|
||||
|
||||
if err := gui.pushContext(gui.Contexts.BranchCommits); err != nil {
|
||||
if err := gui.pushContext(gui.State.Contexts.BranchCommits); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@ func (gui *Gui) handleOpenSearch(viewName string) error {
|
||||
|
||||
gui.renderString("search", "")
|
||||
|
||||
if err := gui.pushContext(gui.Contexts.Search); err != nil {
|
||||
if err := gui.pushContext(gui.State.Contexts.Search); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ func (gui *Gui) handleTogglePanel() error {
|
||||
func (gui *Gui) handleStagingEscape() error {
|
||||
gui.escapeLineByLinePanel()
|
||||
|
||||
return gui.pushContext(gui.Contexts.Files)
|
||||
return gui.pushContext(gui.State.Contexts.Files)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleToggleStagedSelection() error {
|
||||
@ -107,7 +107,7 @@ func (gui *Gui) handleResetSelection() error {
|
||||
handlersManageFocus: true,
|
||||
handleConfirm: func() error {
|
||||
return gui.withLBLActiveCheck(func(state *lBlPanelState) error {
|
||||
if err := gui.pushContext(gui.Contexts.Staging); err != nil {
|
||||
if err := gui.pushContext(gui.State.Contexts.Staging); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ func (gui *Gui) handleResetSelection() error {
|
||||
})
|
||||
},
|
||||
handleClose: func() error {
|
||||
return gui.pushContext(gui.Contexts.Staging)
|
||||
return gui.pushContext(gui.State.Contexts.Staging)
|
||||
},
|
||||
})
|
||||
} else {
|
||||
|
@ -39,7 +39,7 @@ func (gui *Gui) handleStashEntrySelect() error {
|
||||
func (gui *Gui) refreshStashEntries() error {
|
||||
gui.State.StashEntries = gui.GitCommand.GetStashEntries(gui.State.Modes.Filtering.GetPath())
|
||||
|
||||
return gui.Contexts.Stash.HandleRender()
|
||||
return gui.State.Contexts.Stash.HandleRender()
|
||||
}
|
||||
|
||||
// specific functions
|
||||
@ -134,5 +134,5 @@ func (gui *Gui) handleViewStashFiles() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
return gui.switchToCommitFilesContext(stashEntry.RefName(), false, gui.Contexts.Stash, "stash")
|
||||
return gui.switchToCommitFilesContext(stashEntry.RefName(), false, gui.State.Contexts.Stash, "stash")
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ func (gui *Gui) handleStatusClick() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := gui.pushContext(gui.Contexts.Status); err != nil {
|
||||
if err := gui.pushContext(gui.State.Contexts.Status); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ func (gui *Gui) handleViewSubCommitFiles() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
return gui.switchToCommitFilesContext(commit.Sha, false, gui.Contexts.SubCommits, "branches")
|
||||
return gui.switchToCommitFilesContext(commit.Sha, false, gui.State.Contexts.SubCommits, "branches")
|
||||
}
|
||||
|
||||
func (gui *Gui) switchToSubCommitsContext(refName string) error {
|
||||
@ -94,9 +94,9 @@ func (gui *Gui) switchToSubCommitsContext(refName string) error {
|
||||
gui.State.SubCommits = commits
|
||||
gui.State.Panels.SubCommits.refName = refName
|
||||
gui.State.Panels.SubCommits.SelectedLineIdx = 0
|
||||
gui.Contexts.SubCommits.SetParentContext(gui.currentSideContext())
|
||||
gui.State.Contexts.SubCommits.SetParentContext(gui.currentSideContext())
|
||||
|
||||
return gui.pushContext(gui.Contexts.SubCommits)
|
||||
return gui.pushContext(gui.State.Contexts.SubCommits)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleSwitchToSubCommits() error {
|
||||
|
@ -32,5 +32,5 @@ func (gui *Gui) setSuggestions(suggestions []*types.Suggestion) {
|
||||
gui.State.Suggestions = suggestions
|
||||
gui.State.Panels.Suggestions.SelectedLineIdx = 0
|
||||
_ = gui.resetOrigin(view)
|
||||
_ = gui.Contexts.Suggestions.HandleRender()
|
||||
_ = gui.State.Contexts.Suggestions.HandleRender()
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func (gui *Gui) refreshTags() error {
|
||||
|
||||
gui.State.Tags = tags
|
||||
|
||||
return gui.postRefreshUpdate(gui.Contexts.Tags)
|
||||
return gui.postRefreshUpdate(gui.State.Contexts.Tags)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleCheckoutTag() error {
|
||||
@ -55,7 +55,7 @@ func (gui *Gui) handleCheckoutTag() error {
|
||||
if err := gui.handleCheckoutRef(tag.Name, handleCheckoutRefOptions{}); err != nil {
|
||||
return err
|
||||
}
|
||||
return gui.pushContext(gui.Contexts.Branches)
|
||||
return gui.pushContext(gui.State.Contexts.Branches)
|
||||
}
|
||||
|
||||
func (gui *Gui) handleDeleteTag() error {
|
||||
@ -123,7 +123,7 @@ func (gui *Gui) handleCreateTag() error {
|
||||
for i, tag := range gui.State.Tags {
|
||||
if tag.Name == tagName {
|
||||
gui.State.Panels.Tags.SelectedLineIdx = i
|
||||
if err := gui.Contexts.Tags.HandleRender(); err != nil {
|
||||
if err := gui.State.Contexts.Tags.HandleRender(); err != nil {
|
||||
gui.Log.Error(err)
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ func (gui *Gui) getViewNameForWindow(window string) string {
|
||||
|
||||
func (gui *Gui) getWindowForViewName(viewName string) string {
|
||||
if viewName == "commitFiles" {
|
||||
return gui.Contexts.CommitFiles.GetWindowName()
|
||||
return gui.State.Contexts.CommitFiles.GetWindowName()
|
||||
}
|
||||
|
||||
return viewName
|
||||
|
10
vendor/github.com/jesseduffield/gocui/tcell_driver.go
generated
vendored
10
vendor/github.com/jesseduffield/gocui/tcell_driver.go
generated
vendored
@ -5,6 +5,8 @@
|
||||
package gocui
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/gdamore/tcell/v2"
|
||||
)
|
||||
|
||||
@ -21,6 +23,7 @@ type oldStyle struct {
|
||||
// we're using this cache to speed up rendering, because obtaining the tcell style
|
||||
// from the old style is deterministic
|
||||
var cellStyleCache map[oldStyle]tcell.Style = map[oldStyle]tcell.Style{}
|
||||
var cacheMutex = sync.RWMutex{}
|
||||
|
||||
// tcellInit initializes tcell screen for use.
|
||||
func tcellInit() error {
|
||||
@ -43,7 +46,10 @@ func tcellSetCell(x, y int, ch rune, fg, bg Attribute, outputMode OutputMode) {
|
||||
|
||||
// getTcellStyle creates tcell.Style from Attributes
|
||||
func getTcellStyle(input oldStyle) tcell.Style {
|
||||
if cachedResult, ok := cellStyleCache[input]; ok {
|
||||
cacheMutex.RLock()
|
||||
cachedResult, ok := cellStyleCache[input]
|
||||
cacheMutex.RUnlock()
|
||||
if ok {
|
||||
return cachedResult
|
||||
}
|
||||
|
||||
@ -59,7 +65,9 @@ func getTcellStyle(input oldStyle) tcell.Style {
|
||||
st = setTcellFontEffectStyle(st, input.bg)
|
||||
}
|
||||
|
||||
cacheMutex.Lock()
|
||||
cellStyleCache[input] = st
|
||||
cacheMutex.Unlock()
|
||||
|
||||
return st
|
||||
}
|
||||
|
10
vendor/golang.org/x/sys/windows/security_windows.go
generated
vendored
10
vendor/golang.org/x/sys/windows/security_windows.go
generated
vendored
@ -1342,7 +1342,15 @@ func (selfRelativeSD *SECURITY_DESCRIPTOR) copySelfRelativeSecurityDescriptor()
|
||||
h.Len = sdLen
|
||||
h.Cap = sdLen
|
||||
|
||||
dst := make([]byte, sdLen)
|
||||
const psize = int(unsafe.Sizeof(uintptr(0)))
|
||||
|
||||
var dst []byte
|
||||
h = (*unsafeheader.Slice)(unsafe.Pointer(&dst))
|
||||
alloc := make([]uintptr, (sdLen+psize-1)/psize)
|
||||
h.Data = (*unsafeheader.Slice)(unsafe.Pointer(&alloc)).Data
|
||||
h.Len = sdLen
|
||||
h.Cap = sdLen
|
||||
|
||||
copy(dst, src)
|
||||
return (*SECURITY_DESCRIPTOR)(unsafe.Pointer(&dst[0]))
|
||||
}
|
||||
|
4
vendor/modules.txt
vendored
4
vendor/modules.txt
vendored
@ -149,7 +149,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem
|
||||
github.com/jesseduffield/go-git/v5/utils/merkletrie/index
|
||||
github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame
|
||||
github.com/jesseduffield/go-git/v5/utils/merkletrie/noder
|
||||
# github.com/jesseduffield/gocui v0.3.1-0.20210402113210-6fd7ef27ce76
|
||||
# github.com/jesseduffield/gocui v0.3.1-0.20210403045716-a3be78c4ccf6
|
||||
## explicit
|
||||
github.com/jesseduffield/gocui
|
||||
# github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe
|
||||
@ -235,7 +235,7 @@ golang.org/x/crypto/ssh/knownhosts
|
||||
golang.org/x/net/context
|
||||
golang.org/x/net/internal/socks
|
||||
golang.org/x/net/proxy
|
||||
# golang.org/x/sys v0.0.0-20210331175145-43e1dd70ce54
|
||||
# golang.org/x/sys v0.0.0-20210402192133-700132347e07
|
||||
## explicit
|
||||
golang.org/x/sys/cpu
|
||||
golang.org/x/sys/internal/unsafeheader
|
||||
|
Loading…
Reference in New Issue
Block a user