summaryrefslogtreecommitdiffstats
path: root/pkg/gui/view_helpers.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-09-26 10:23:10 +1000
committerJesse Duffield <jessedduffield@gmail.com>2020-09-26 11:00:50 +1000
commit077f11361805417c15234c62a9f9aa022f913d43 (patch)
tree2cf25beba4f96b55392f09d733a14c25c149de07 /pkg/gui/view_helpers.go
parent0c6cbe7746660155df0645f01d37150099d21f49 (diff)
add in-built logging support for a better dev experience
Diffstat (limited to 'pkg/gui/view_helpers.go')
-rw-r--r--pkg/gui/view_helpers.go47
1 files changed, 46 insertions, 1 deletions
diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go
index 796b7dca6..d7eab73ba 100644
--- a/pkg/gui/view_helpers.go
+++ b/pkg/gui/view_helpers.go
@@ -27,6 +27,39 @@ const (
STATUS
)
+func getScopeNames(scopes []int) []string {
+ scopeNameMap := map[int]string{
+ COMMITS: "commits",
+ BRANCHES: "branches",
+ FILES: "files",
+ STASH: "stash",
+ REFLOG: "reflog",
+ TAGS: "tags",
+ REMOTES: "remotes",
+ STATUS: "status",
+ }
+
+ scopeNames := make([]string, len(scopes))
+ for i, scope := range scopes {
+ scopeNames[i] = scopeNameMap[scope]
+ }
+
+ return scopeNames
+}
+
+func getModeName(mode int) string {
+ switch mode {
+ case SYNC:
+ return "sync"
+ case ASYNC:
+ return "async"
+ case BLOCK_UI:
+ return "block-ui"
+ default:
+ return "unknown mode"
+ }
+}
+
const (
SYNC = iota // wait until everything is done before returning
ASYNC // return immediately, allowing each independent thing to update itself
@@ -48,6 +81,19 @@ func intArrToMap(arr []int) map[int]bool {
}
func (gui *Gui) refreshSidePanels(options refreshOptions) error {
+ if options.scope == nil {
+ gui.Log.Infof(
+ "refreshing all scopes in %s mode",
+ getModeName(options.mode),
+ )
+ } else {
+ gui.Log.Infof(
+ "refreshing the following scopes in %s mode: %s",
+ getModeName(options.mode),
+ strings.Join(getScopeNames(options.scope), ","),
+ )
+ }
+
wg := sync.WaitGroup{}
f := func() {
@@ -283,7 +329,6 @@ func (gui *Gui) resizePopupPanel(v *gocui.View) error {
if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 {
return nil
}
- gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel"))
_, err := gui.g.SetView(v.Name(), x0, y0, x1, y1, 0)
return err
}