From f4718a904769b372b52cf3cd2c890b34d751620a Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Tue, 21 Jul 2020 18:12:05 +1000 Subject: allow editing commit files --- docs/keybindings/Keybindings_en.md | 1 + docs/keybindings/Keybindings_nl.md | 1 + docs/keybindings/Keybindings_pl.md | 1 + pkg/gui/commit_files_panel.go | 13 +++++++++++++ pkg/gui/keybindings.go | 6 ++++++ 5 files changed, 22 insertions(+) diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index c4ea18d97..1c8a29d91 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -104,6 +104,7 @@ c: checkout file d: discard this commit's changes to this file o: open file + e: edit file space: toggle file included in patch enter: enter file to add selected lines to the patch ,: previous page diff --git a/docs/keybindings/Keybindings_nl.md b/docs/keybindings/Keybindings_nl.md index f3bd9b37d..51c87919b 100644 --- a/docs/keybindings/Keybindings_nl.md +++ b/docs/keybindings/Keybindings_nl.md @@ -104,6 +104,7 @@ c: bestand uitchecken d: uitsluit deze commit zijn veranderingen aan dit bestand o: open bestand + e: verander bestand space: toggle file included in patch enter: enter file to add selected lines to the patch ,: previous page diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index 3ea71d5d0..cab96715f 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -104,6 +104,7 @@ c: checkout file d: discard this commit's changes to this file o: otwórz plik + e: edytuj plik space: toggle file included in patch enter: enter file to add selected lines to the patch ,: previous page diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index 4870876c0..886fe3d7b 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -121,9 +121,22 @@ func (gui *Gui) refreshCommitFilesView() error { func (gui *Gui) handleOpenOldCommitFile(g *gocui.Gui, v *gocui.View) error { file := gui.getSelectedCommitFile() + if file == nil { + return nil + } + return gui.openFile(file.Name) } +func (gui *Gui) handleEditCommitFile(g *gocui.Gui, v *gocui.View) error { + file := gui.getSelectedCommitFile() + if file == nil { + return nil + } + + return gui.editFile(file.Name) +} + func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error { if ok, err := gui.validateNormalWorkingTreeState(); !ok { return err diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 283daa779..66d9f086f 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -878,6 +878,12 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Handler: gui.handleOpenOldCommitFile, Description: gui.Tr.SLocalize("openFile"), }, + { + ViewName: "commitFiles", + Key: gui.getKey("universal.edit"), + Handler: gui.handleEditCommitFile, + Description: gui.Tr.SLocalize("editFile"), + }, { ViewName: "commitFiles", Key: gui.getKey("universal.select"), -- cgit v1.2.3