1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-06 11:02:41 +03:00

feat(merge_panel): Add open/edit files in merge conflict panel

This commit is contained in:
Ryooooooga
2022-04-04 21:12:33 +09:00
committed by Jesse Duffield
parent 53257db99d
commit 3b5a019e1a
7 changed files with 52 additions and 0 deletions

View File

@@ -146,6 +146,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<kbd></kbd>: select next conflict <kbd></kbd>: select next conflict
<kbd></kbd>: select previous hunk <kbd></kbd>: select previous hunk
<kbd></kbd>: select next hunk <kbd></kbd>: select next hunk
<kbd>e</kbd>: edit file
<kbd>o</kbd>: open file
<kbd>z</kbd>: undo <kbd>z</kbd>: undo
</pre> </pre>

View File

@@ -146,6 +146,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<kbd></kbd>: selecteer volgende conflict <kbd></kbd>: selecteer volgende conflict
<kbd></kbd>: selecteer bovenste hunk <kbd></kbd>: selecteer bovenste hunk
<kbd></kbd>: selecteer onderste hunk <kbd></kbd>: selecteer onderste hunk
<kbd>e</kbd>: verander bestand
<kbd>o</kbd>: open bestand
<kbd>z</kbd>: ongedaan maken <kbd>z</kbd>: ongedaan maken
</pre> </pre>

View File

@@ -219,6 +219,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<kbd></kbd>: następny konflikt <kbd></kbd>: następny konflikt
<kbd></kbd>: wybierz poprzedni kawałek <kbd></kbd>: wybierz poprzedni kawałek
<kbd></kbd>: wybierz następny kawałek <kbd></kbd>: wybierz następny kawałek
<kbd>e</kbd>: edytuj plik
<kbd>o</kbd>: otwórz plik
<kbd>z</kbd>: cofnij <kbd>z</kbd>: cofnij
</pre> </pre>

View File

@@ -216,6 +216,8 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<kbd></kbd>: 选择下一个冲突 <kbd></kbd>: 选择下一个冲突
<kbd></kbd>: 选择顶部块 <kbd></kbd>: 选择顶部块
<kbd></kbd>: 选择底部块 <kbd></kbd>: 选择底部块
<kbd>e</kbd>: 编辑文件
<kbd>o</kbd>: 打开文件
<kbd>z</kbd>: 撤销 <kbd>z</kbd>: 撤销
</pre> </pre>

View File

@@ -671,6 +671,20 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
Modifier: gocui.ModNone, Modifier: gocui.ModNone,
Handler: self.handleSelectNextConflictHunk, Handler: self.handleSelectNextConflictHunk,
}, },
{
ViewName: "main",
Contexts: []string{string(context.MAIN_MERGING_CONTEXT_KEY)},
Key: opts.GetKey(opts.Config.Universal.Edit),
Handler: self.handleMergeConflictEditFileAtLine,
Description: self.c.Tr.LcEditFile,
},
{
ViewName: "main",
Contexts: []string{string(context.MAIN_MERGING_CONTEXT_KEY)},
Key: opts.GetKey(opts.Config.Universal.OpenFile),
Handler: self.handleMergeConflictOpenFileAtLine,
Description: self.c.Tr.LcOpenFile,
},
{ {
ViewName: "main", ViewName: "main",
Contexts: []string{string(context.MAIN_MERGING_CONTEXT_KEY)}, Contexts: []string{string(context.MAIN_MERGING_CONTEXT_KEY)},

View File

@@ -299,3 +299,23 @@ func (gui *Gui) switchToMerge(path string) error {
return gui.c.PushContext(gui.State.Contexts.Merging) return gui.c.PushContext(gui.State.Contexts.Merging)
} }
func (gui *Gui) handleMergeConflictEditFileAtLine() error {
file := gui.getSelectedFile()
if file == nil {
return nil
}
lineNumber := gui.State.Panels.Merging.GetSelectedLine()
return gui.helpers.Files.EditFileAtLine(file.GetPath(), lineNumber)
}
func (gui *Gui) handleMergeConflictOpenFileAtLine() error {
file := gui.getSelectedFile()
if file == nil {
return nil
}
lineNumber := gui.State.Panels.Merging.GetSelectedLine()
return gui.helpers.Files.OpenFileAtLine(file.GetPath(), lineNumber)
}

View File

@@ -182,3 +182,13 @@ func (s *State) ContentAfterConflictResolve(selection Selection) (bool, string,
return true, content, nil return true, content, nil
} }
func (s *State) GetSelectedLine() int {
conflict := s.currentConflict()
if conflict == nil {
return 1
}
selection := s.Selection()
startIndex, _ := selection.bounds(conflict)
return startIndex + 1
}