diff options
Diffstat (limited to 'pkg/gui/view_helpers.go')
-rw-r--r-- | pkg/gui/view_helpers.go | 135 |
1 files changed, 0 insertions, 135 deletions
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 42ff9d5d8..202504c10 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -4,7 +4,6 @@ import ( "fmt" "sort" "strings" - "sync" "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/gui/types" @@ -16,140 +15,6 @@ func (gui *Gui) getCyclableWindows() []string { return []string{"status", "files", "branches", "commits", "stash"} } -func getScopeNames(scopes []types.RefreshableView) []string { - scopeNameMap := map[types.RefreshableView]string{ - types.COMMITS: "commits", - types.BRANCHES: "branches", - types.FILES: "files", - types.SUBMODULES: "submodules", - types.STASH: "stash", - types.REFLOG: "reflog", - types.TAGS: "tags", - types.REMOTES: "remotes", - types.STATUS: "status", - types.BISECT_INFO: "bisect", - } - - scopeNames := make([]string, len(scopes)) - for i, scope := range scopes { - scopeNames[i] = scopeNameMap[scope] - } - - return scopeNames -} - -func getModeName(mode types.RefreshMode) string { - switch mode { - case types.SYNC: - return "sync" - case types.ASYNC: - return "async" - case types.BLOCK_UI: - return "block-ui" - default: - return "unknown mode" - } -} - -func arrToMap(arr []types.RefreshableView) map[types.RefreshableView]bool { - output := map[types.RefreshableView]bool{} - for _, el := range arr { - output[el] = true - } - return output -} - -func (gui *Gui) Refresh(options types.RefreshOptions) error { - if options.Scope == nil { - gui.c.Log.Infof( - "refreshing all scopes in %s mode", - getModeName(options.Mode), - ) - } else { - gui.c.Log.Infof( - "refreshing the following scopes in %s mode: %s", - getModeName(options.Mode), - strings.Join(getScopeNames(options.Scope), ","), - ) - } - - wg := sync.WaitGroup{} - - f := func() { - var scopeMap map[types.RefreshableView]bool - if len(options.Scope) == 0 { - scopeMap = arrToMap([]types.RefreshableView{ - types.COMMITS, - types.BRANCHES, - types.FILES, - types.STASH, - types.REFLOG, - types.TAGS, - types.REMOTES, - types.STATUS, - types.BISECT_INFO, - }) - } else { - scopeMap = arrToMap(options.Scope) - } - - refresh := func(f func()) { - wg.Add(1) - func() { - if options.Mode == types.ASYNC { - go utils.Safe(f) - } else { - f() - } - wg.Done() - }() - } - - if scopeMap[types.COMMITS] || scopeMap[types.BRANCHES] || scopeMap[types.REFLOG] || scopeMap[types.BISECT_INFO] { - refresh(gui.refreshCommits) - } else if scopeMap[types.REBASE_COMMITS] { - // the above block handles rebase commits so we only need to call this one - // if we've asked specifically for rebase commits and not those other things - refresh(func() { _ = gui.refreshRebaseCommits() }) - } - - if scopeMap[types.FILES] || scopeMap[types.SUBMODULES] { - refresh(func() { _ = gui.refreshFilesAndSubmodules() }) - } - - if scopeMap[types.STASH] { - refresh(func() { _ = gui.refreshStashEntries() }) - } - - if scopeMap[types.TAGS] { - refresh(func() { _ = gui.refreshTags() }) - } - - if scopeMap[types.REMOTES] { - refresh(func() { _ = gui.refreshRemotes() }) - } - - wg.Wait() - - gui.refreshStatus() - - if options.Then != nil { - options.Then() - } - } - - if options.Mode == types.BLOCK_UI { - gui.OnUIThread(func() error { - f() - return nil - }) - } else { - f() - } - - return nil -} - func (gui *Gui) resetOrigin(v *gocui.View) error { _ = v.SetCursor(0, 0) return v.SetOrigin(0, 0) |