diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2023-05-16 20:45:43 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2023-05-16 21:01:38 +1000 |
commit | a82134f41c60622166ad56c2b2c7f83e1989be77 (patch) | |
tree | 389b3519d4466a8080280b6dbee2ea53f2ad2417 /pkg/gui/controllers/helpers | |
parent | 00b03079d88464916528df720d8b85f08ce6a6a3 (diff) |
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
Diffstat (limited to 'pkg/gui/controllers/helpers')
-rw-r--r-- | pkg/gui/controllers/helpers/merge_conflicts_helper.go | 10 |
1 files changed, 9 insertions, 1 deletions
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 } |