From 0f7003d939a969920ffdb5f2d28fca2fd0eb7f65 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sun, 23 Aug 2020 21:25:39 +1000 Subject: [PATCH] allow spamming the p key --- pkg/gui/files_panel.go | 3 +++ pkg/gui/global_handlers.go | 3 +++ pkg/gui/gui.go | 1 + pkg/gui/remotes_panel.go | 3 +++ 4 files changed, 10 insertions(+) diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index c4798c854..f983f5033 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -475,6 +475,9 @@ func (gui *Gui) pullFiles(opts PullFilesOptions) error { } func (gui *Gui) pullWithMode(mode string, opts PullFilesOptions) error { + gui.State.FetchMutex.Lock() + defer gui.State.FetchMutex.Unlock() + err := gui.GitCommand.Fetch( commands.FetchOptions{ PromptUserForCredential: gui.promptUserForCredential, diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go index 1129f63fd..d5b25f738 100644 --- a/pkg/gui/global_handlers.go +++ b/pkg/gui/global_handlers.go @@ -165,6 +165,9 @@ func (gui *Gui) handleInfoClick(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) fetch(canPromptForCredentials bool) (err error) { + gui.State.FetchMutex.Lock() + defer gui.State.FetchMutex.Unlock() + fetchOpts := commands.FetchOptions{} if canPromptForCredentials { fetchOpts.PromptUserForCredential = gui.promptUserForCredential diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index b61170b30..bc6448374 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -287,6 +287,7 @@ type guiState struct { IsRefreshingFiles bool RefreshingFilesMutex sync.Mutex RefreshingStatusMutex sync.Mutex + FetchMutex sync.Mutex Searching searchingState ScreenMode int SideView *gocui.View diff --git a/pkg/gui/remotes_panel.go b/pkg/gui/remotes_panel.go index 92b0e0ffe..e32eb77c6 100644 --- a/pkg/gui/remotes_panel.go +++ b/pkg/gui/remotes_panel.go @@ -158,6 +158,9 @@ func (gui *Gui) handleFetchRemote(g *gocui.Gui, v *gocui.View) error { } return gui.WithWaitingStatus(gui.Tr.SLocalize("FetchingRemoteStatus"), func() error { + gui.State.FetchMutex.Lock() + defer gui.State.FetchMutex.Unlock() + if err := gui.GitCommand.FetchRemote(remote.Name); err != nil { return err }