From 6ca42ff72081624fc05be571d75ab71dd1d9bf6b Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Tue, 24 Aug 2021 21:33:19 +0900 Subject: [PATCH] Fix `pick all hunks` --- pkg/gui/merge_panel.go | 6 +++--- pkg/gui/mergeconflicts/state.go | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pkg/gui/merge_panel.go b/pkg/gui/merge_panel.go index 0206ba164..ae3019da3 100644 --- a/pkg/gui/merge_panel.go +++ b/pkg/gui/merge_panel.go @@ -99,7 +99,7 @@ func (gui *Gui) handlePickBothHunks() error { return gui.withMergeConflictLock(func() error { gui.takeOverMergeConflictScrolling() - ok, err := gui.resolveConflict(mergeconflicts.BOTH) + ok, err := gui.resolveConflict(mergeconflicts.ALL) if err != nil { return err } @@ -139,8 +139,8 @@ func (gui *Gui) resolveConflict(selection mergeconflicts.Selection) (bool, error logStr = "Picking middle hunk" case mergeconflicts.BOTTOM: logStr = "Picking bottom hunk" - case mergeconflicts.BOTH: - logStr = "Picking both hunks" + case mergeconflicts.ALL: + logStr = "Picking all hunks" } gui.OnRunCommand(oscommands.NewCmdLogEntry(logStr, "Resolve merge conflict", false)) return true, ioutil.WriteFile(gitFile.Name, []byte(output), 0644) diff --git a/pkg/gui/mergeconflicts/state.go b/pkg/gui/mergeconflicts/state.go index 69d90d573..da2f628a6 100644 --- a/pkg/gui/mergeconflicts/state.go +++ b/pkg/gui/mergeconflicts/state.go @@ -22,7 +22,7 @@ const ( TOP Selection = iota MIDDLE BOTTOM - BOTH + ALL ) // mergeConflict : A git conflict with a start, ancestor (if exists), target, and end corresponding to line @@ -179,6 +179,12 @@ func isIndexToDelete(i int, conflict *mergeConflict, selection Selection) bool { return false } + isMarkerLine := + i == conflict.start || + i == conflict.ancestor || + i == conflict.target || + i == conflict.end + var isWantedContent bool switch selection { case TOP: @@ -191,7 +197,9 @@ func isIndexToDelete(i int, conflict *mergeConflict, selection Selection) bool { isWantedContent = conflict.ancestor < i && i < conflict.target case BOTTOM: isWantedContent = conflict.target < i && i < conflict.end + case ALL: + isWantedContent = true } - return !isWantedContent + return isMarkerLine || !isWantedContent }