Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs-master/keybindings/Keybindings_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| Key | Action | Info |
|-----|--------|-------------|
| `` <space> `` | Pick hunk | |
| `` b `` | Pick all hunks | |
| `` b `` | Pick both hunks | |
| `` <up>, k `` | Previous hunk | |
| `` <down>, j `` | Next hunk | |
| `` <left>, h `` | Previous conflict | |
Expand Down
2 changes: 1 addition & 1 deletion docs-master/keybindings/Keybindings_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| Key | Action | Info |
|-----|--------|-------------|
| `` <space> `` | ハンクを選択 | |
| `` b `` | すべてのハンクを選択 | |
| `` b `` | Pick both hunks | |
| `` <up>, k `` | 前のハンク | |
| `` <down>, j `` | 次のハンク | |
| `` <left>, h `` | 前のコンフリクト | |
Expand Down
2 changes: 1 addition & 1 deletion docs-master/keybindings/Keybindings_ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| Key | Action | Info |
|-----|--------|-------------|
| `` <space> `` | Pick hunk | |
| `` b `` | Pick all hunks | |
| `` b `` | Pick both hunks | |
| `` <up>, k `` | 이전 hunk를 선택 | |
| `` <down>, j `` | 다음 hunk를 선택 | |
| `` <left>, h `` | 이전 충돌을 선택 | |
Expand Down
2 changes: 1 addition & 1 deletion docs-master/keybindings/Keybindings_nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| Key | Action | Info |
|-----|--------|-------------|
| `` <space> `` | Kies stuk | |
| `` b `` | Kies beide stukken | |
| `` b `` | Pick both hunks | |
| `` <up>, k `` | Selecteer bovenste hunk | |
| `` <down>, j `` | Selecteer onderste hunk | |
| `` <left>, h `` | Selecteer voorgaand conflict | |
Expand Down
2 changes: 1 addition & 1 deletion docs-master/keybindings/Keybindings_pl.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| Key | Action | Info |
|-----|--------|-------------|
| `` <space> `` | Wybierz fragment | |
| `` b `` | Wybierz wszystkie fragmenty | |
| `` b `` | Pick both hunks | |
| `` <up>, k `` | Poprzedni fragment | |
| `` <down>, j `` | Następny fragment | |
| `` <left>, h `` | Poprzedni konflikt | |
Expand Down
2 changes: 1 addition & 1 deletion docs-master/keybindings/Keybindings_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| Key | Action | Info |
|-----|--------|-------------|
| `` <space> `` | Escolha o local | |
| `` b `` | Pegar todos os pedaços | |
| `` b `` | Pick both hunks | |
| `` <up>, k `` | Trecho anterior | |
| `` <down>, j `` | Próximo trecho | |
| `` <left>, h `` | Conflito anterior | |
Expand Down
2 changes: 1 addition & 1 deletion docs-master/keybindings/Keybindings_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| Key | Action | Info |
|-----|--------|-------------|
| `` <space> `` | Выбрать эту часть | |
| `` b `` | Выбрать все части | |
| `` b `` | Pick both hunks | |
| `` <up>, k `` | Выбрать предыдущую часть | |
| `` <down>, j `` | Выбрать следующую часть | |
| `` <left>, h `` | Выбрать предыдущий конфликт | |
Expand Down
2 changes: 1 addition & 1 deletion docs-master/keybindings/Keybindings_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| Key | Action | Info |
|-----|--------|-------------|
| `` <space> `` | 选中区块 | |
| `` b `` | 选中所有区块 | |
| `` b `` | Pick both hunks | |
| `` <up>, k `` | 选择顶部块 | |
| `` <down>, j `` | 选择底部块 | |
| `` <left>, h `` | 选择上一个冲突 | |
Expand Down
2 changes: 1 addition & 1 deletion docs-master/keybindings/Keybindings_zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| Key | Action | Info |
|-----|--------|-------------|
| `` <space> `` | 挑選程式碼片段 | |
| `` b `` | 挑選所有程式碼片段 | |
| `` b `` | Pick both hunks | |
| `` <up>, k `` | 選擇上一段 | |
| `` <down>, j `` | 選擇下一段 | |
| `` <left>, h `` | 選擇上一個衝突 | |
Expand Down
12 changes: 6 additions & 6 deletions pkg/gui/controllers/merge_conflicts_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func (self *MergeConflictsController) GetKeybindings(opts types.KeybindingsOpts)
},
{
Keys: opts.GetKeys(opts.Config.Main.PickBothHunks),
Handler: self.withRenderAndFocus(self.HandlePickAllHunks),
Description: self.c.Tr.PickAllHunks,
Handler: self.withRenderAndFocus(self.HandlePickBothHunks),
Description: self.c.Tr.PickBothHunks,
DisplayOnScreen: true,
},
{
Expand Down Expand Up @@ -247,8 +247,8 @@ func (self *MergeConflictsController) HandlePickHunk() error {
return self.pickSelection(self.context().GetState().Selection())
}

func (self *MergeConflictsController) HandlePickAllHunks() error {
return self.pickSelection(mergeconflicts.ALL)
func (self *MergeConflictsController) HandlePickBothHunks() error {
return self.pickSelection(mergeconflicts.BOTH)
}

func (self *MergeConflictsController) pickSelection(selection mergeconflicts.Selection) error {
Expand Down Expand Up @@ -290,8 +290,8 @@ func (self *MergeConflictsController) resolveConflict(selection mergeconflicts.S
logStr = "Picking middle hunk"
case mergeconflicts.BOTTOM:
logStr = "Picking bottom hunk"
case mergeconflicts.ALL:
logStr = "Picking all hunks"
case mergeconflicts.BOTH:
logStr = "Picking both hunks"
}
self.c.LogAction("Resolve merge conflict")
self.c.LogCommand(logStr, false)
Expand Down
15 changes: 12 additions & 3 deletions pkg/gui/mergeconflicts/merge_conflict.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const (
TOP Selection = iota
MIDDLE
BOTTOM
ALL
BOTH
)

func (s Selection) isIndexToKeep(conflict *mergeConflict, i int) bool {
Expand Down Expand Up @@ -56,14 +56,23 @@ func (s Selection) bounds(c *mergeConflict) (int, int) {
return c.ancestor, c.target
case BOTTOM:
return c.target, c.end
case ALL:
return c.start, c.end
case BOTH:
// BOTH spans two disjoint hunks, so it has no single range; callers
// go through selected() instead of asking for its bounds.
panic("BOTH has no single range")
}

panic("unexpected selection for merge conflict")
}

func (s Selection) selected(c *mergeConflict, idx int) bool {
// BOTH keeps the top and bottom hunks but drops the common ancestor in
// between (which is only present with the diff3 conflict style), so it
// isn't a single contiguous range like the other selections.
if s == BOTH {
return TOP.selected(c, idx) || BOTTOM.selected(c, idx)
}

start, end := s.bounds(c)
return start < idx && idx < end
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ type TranslationSet struct {
ViewConflictsMenuItem string
AbortMenuItem string
PickHunk string
PickAllHunks string
PickBothHunks string
ViewMergeRebaseOptions string
ViewMergeRebaseOptionsTooltip string
ViewMergeOptions string
Expand Down Expand Up @@ -1338,7 +1338,7 @@ func EnglishTranslationSet() *TranslationSet {
RewordCommitEditor: "Reword with editor",
Error: "Error",
PickHunk: "Pick hunk",
PickAllHunks: "Pick all hunks",
PickBothHunks: "Pick both hunks",
Undo: "Undo",
UndoReflog: "Undo",
RedoReflog: "Redo",
Expand Down
41 changes: 41 additions & 0 deletions pkg/integration/tests/conflicts/pick_both_hunks_diff3.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package conflicts

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
"github.com/jesseduffield/lazygit/pkg/integration/tests/shared"
)

var PickBothHunksDiff3 = NewIntegrationTest(NewIntegrationTestArgs{
Description: "Pick both hunks of a conflict rendered in the diff3 style; the common ancestor must not be included",
ExtraCmdArgs: []string{},
Skip: false,
SetupConfig: func(config *config.AppConfig) {},
SetupRepo: func(shell *Shell) {
shell.SetConfig("merge.conflictStyle", "diff3")
shared.CreateMergeConflictFile(shell)
},
Run: func(t *TestDriver, keys config.KeybindingConfig) {
t.Views().Files().
IsFocused().
Lines(
Contains("UU file").IsSelected(),
).
PressEnter()

t.Views().MergeConflicts().
IsFocused().
// the diff3 style renders the common ancestor between the two changes
Content(Contains("<<<<<<< HEAD\nFirst Change")).
Content(Contains("||||||| ")).
Content(Contains("Original")).
Press(keys.Main.PickBothHunks)

t.Common().ContinueOnConflictsResolved("merge")

t.Views().Files().IsEmpty()

t.FileSystem().FileContent("file",
Equals("\nThis\nIs\nThe\nFirst Change\nSecond Change\nFile\n"))
},
})
1 change: 1 addition & 0 deletions pkg/integration/tests/test_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ var tests = []*components.IntegrationTest{
conflicts.MergeFileBoth,
conflicts.MergeFileCurrent,
conflicts.MergeFileIncoming,
conflicts.PickBothHunksDiff3,
conflicts.ResolveExternally,
conflicts.ResolveMultipleFiles,
conflicts.ResolveNoAutoStage,
Expand Down
Loading