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:
committed by
Jesse Duffield
parent
53257db99d
commit
3b5a019e1a
@@ -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 previous hunk
|
||||
<kbd>▼</kbd>: select next hunk
|
||||
<kbd>e</kbd>: edit file
|
||||
<kbd>o</kbd>: open file
|
||||
<kbd>z</kbd>: undo
|
||||
</pre>
|
||||
|
||||
|
@@ -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 bovenste hunk
|
||||
<kbd>▼</kbd>: selecteer onderste hunk
|
||||
<kbd>e</kbd>: verander bestand
|
||||
<kbd>o</kbd>: open bestand
|
||||
<kbd>z</kbd>: ongedaan maken
|
||||
</pre>
|
||||
|
||||
|
@@ -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>: wybierz poprzedni kawałek
|
||||
<kbd>▼</kbd>: wybierz następny kawałek
|
||||
<kbd>e</kbd>: edytuj plik
|
||||
<kbd>o</kbd>: otwórz plik
|
||||
<kbd>z</kbd>: cofnij
|
||||
</pre>
|
||||
|
||||
|
@@ -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>e</kbd>: 编辑文件
|
||||
<kbd>o</kbd>: 打开文件
|
||||
<kbd>z</kbd>: 撤销
|
||||
</pre>
|
||||
|
||||
|
@@ -671,6 +671,20 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi
|
||||
Modifier: gocui.ModNone,
|
||||
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",
|
||||
Contexts: []string{string(context.MAIN_MERGING_CONTEXT_KEY)},
|
||||
|
@@ -299,3 +299,23 @@ func (gui *Gui) switchToMerge(path string) error {
|
||||
|
||||
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)
|
||||
}
|
||||
|
@@ -182,3 +182,13 @@ func (s *State) ContentAfterConflictResolve(selection Selection) (bool, string,
|
||||
|
||||
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
|
||||
}
|
||||
|
Reference in New Issue
Block a user