1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

Fix race condition

Our refresh code may try to push a context. It does this in two places:
1) when all merge conflicts are resolved, we push a 'continue merge?' confirmation context
2) when all conflicts of a given file are resolved and we're in the merge conflicts context,
   we push the files context.

Sometimes we push the confirmation context and then push the files context over it, so the user
never sees the confirmation context.

This commit fixes the race condition by adding a check to ensure that we're still in the
merge conflicts panel before we try escaping from it
This commit is contained in:
Jesse Duffield
2023-05-16 20:45:43 +10:00
parent 00b03079d8
commit a82134f41c

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
}