summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-05-16 21:13:17 +1000
committerGitHub <noreply@github.com>2023-05-16 21:13:17 +1000
commitea5fb6a364650777ad7b6ec46050b5369e60545f (patch)
tree389b3519d4466a8080280b6dbee2ea53f2ad2417
parent9514284f8e9f669b32d09af81de57d2bd232fff1 (diff)
parenta82134f41c60622166ad56c2b2c7f83e1989be77 (diff)
Merge pull request #2629 from jesseduffield/try-fix-conflict-continue-prompt
-rw-r--r--pkg/gui/command_log_panel.go3
-rw-r--r--pkg/gui/context.go6
-rw-r--r--pkg/gui/controllers/helpers/merge_conflicts_helper.go10
-rw-r--r--pkg/gui/gui.go6
-rw-r--r--pkg/gui/gui_driver.go2
5 files changed, 19 insertions, 8 deletions
diff --git a/pkg/gui/command_log_panel.go b/pkg/gui/command_log_panel.go
index 258a9cac1..c0aa83bec 100644
--- a/pkg/gui/command_log_panel.go
+++ b/pkg/gui/command_log_panel.go
@@ -30,6 +30,7 @@ func (gui *Gui) LogAction(action string) {
gui.Views.Extras.Autoscroll = true
+ gui.GuiLog = append(gui.GuiLog, action)
fmt.Fprint(gui.Views.Extras, "\n"+style.FgYellow.Sprint(action))
}
@@ -46,7 +47,7 @@ func (gui *Gui) LogCommand(cmdStr string, commandLine bool) {
// we style it differently to communicate that
textStyle = style.FgMagenta
}
- gui.CmdLog = append(gui.CmdLog, cmdStr)
+ gui.GuiLog = append(gui.GuiLog, cmdStr)
indentedCmdStr := " " + strings.Replace(cmdStr, "\n", "\n ", -1)
fmt.Fprint(gui.Views.Extras, "\n"+textStyle.Sprint(indentedCmdStr))
}
diff --git a/pkg/gui/context.go b/pkg/gui/context.go
index d5a7f35a2..b55713f27 100644
--- a/pkg/gui/context.go
+++ b/pkg/gui/context.go
@@ -95,7 +95,7 @@ func (self *ContextMgr) pushToContextStack(c types.Context) ([]types.Context, ty
defer self.Unlock()
if len(self.ContextStack) > 0 &&
- c == self.ContextStack[len(self.ContextStack)-1] {
+ c.GetKey() == self.ContextStack[len(self.ContextStack)-1].GetKey() {
// Context being pushed is already on top of the stack: nothing to
// deactivate or activate
return contextsToDeactivate, nil
@@ -105,7 +105,9 @@ func (self *ContextMgr) pushToContextStack(c types.Context) ([]types.Context, ty
self.ContextStack = append(self.ContextStack, c)
} else if c.GetKind() == types.SIDE_CONTEXT {
// if we are switching to a side context, remove all other contexts in the stack
- contextsToDeactivate = self.ContextStack
+ contextsToDeactivate = lo.Filter(self.ContextStack, func(context types.Context, _ int) bool {
+ return context.GetKey() != c.GetKey()
+ })
self.ContextStack = []types.Context{c}
} else if c.GetKind() == types.MAIN_CONTEXT {
// if we're switching to a main context, remove all other main contexts in the stack
diff --git a/pkg/gui/controllers/helpers/merge_conflicts_helper.go b/pkg/gui/controllers/helpers/merge_conflicts_helper.go
index 3610e28c8..e6a56bfae 100644
--- a/pkg/gui/controllers/helpers/merge_conflicts_helper.go
+++ b/pkg/gui/controllers/helpers/merge_conflicts_helper.go
@@ -56,7 +56,15 @@ func (self *MergeConflictsHelper) EscapeMerge() error {
// doing this in separate UI thread so that we're not still holding the lock by the time refresh the file
self.c.OnUIThread(func() error {
- return self.c.PushContext(self.c.Contexts().Files)
+ // There is a race condition here: refreshing the files scope can trigger the
+ // confirmation context to be pushed if all conflicts are resolved (prompting
+ // to continue the merge/rebase. In that case, we don't want to then push the
+ // files context over it.
+ // So long as both places call OnUIThread, we're fine.
+ if self.c.IsCurrentContext(self.c.Contexts().MergeConflicts) {
+ return self.c.PushContext(self.c.Contexts().Files)
+ }
+ return nil
})
return nil
}
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 6b42da4fc..b429bda27 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -93,8 +93,8 @@ type Gui struct {
Views types.Views
- // Log of the commands that get run, to be displayed to the user.
- CmdLog []string
+ // Log of the commands/actions logged in the Command Log panel.
+ GuiLog []string
// the extras window contains things like the command log
ShowExtrasWindow bool
@@ -440,7 +440,7 @@ func NewGui(
showRecentRepos: showRecentRepos,
RepoPathStack: &utils.StringStack{},
RepoStateMap: map[Repo]*GuiRepoState{},
- CmdLog: []string{},
+ GuiLog: []string{},
// originally we could only hide the command log permanently via the config
// but now we do it via state. So we need to still support the config for the
diff --git a/pkg/gui/gui_driver.go b/pkg/gui/gui_driver.go
index c409ebdb9..a90578b65 100644
--- a/pkg/gui/gui_driver.go
+++ b/pkg/gui/gui_driver.go
@@ -64,7 +64,7 @@ func (self *GuiDriver) Fail(message string) {
"%s\nFinal Lazygit state:\n%s\nUpon failure, focused view was '%s'.\nLog:\n%s", message,
self.gui.g.Snapshot(),
currentView.Name(),
- strings.Join(self.gui.CmdLog, "\n"),
+ strings.Join(self.gui.GuiLog, "\n"),
)
self.gui.g.Close()