1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-05 13:24:54 +02:00

Merge pull request #2629 from jesseduffield/try-fix-conflict-continue-prompt

This commit is contained in:
Jesse Duffield 2023-05-16 21:13:17 +10:00 committed by GitHub
commit ea5fb6a364
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 8 deletions

View File

@ -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))
}

View File

@ -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

View File

@ -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
}

View File

@ -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

View File

@ -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()