diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-11-28 13:35:58 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-11-28 20:48:17 +1100 |
commit | 5671ec5f5867c3c2b083563bac309c8616b322ae (patch) | |
tree | f0cd4ed218be9a4a87b9e60782a2fc97ba2d81cb /pkg/gui/commits_panel.go | |
parent | da3b0bf7c8aa6202d5eb9c8178f6648bc695336a (diff) |
refactor prompt opts
Diffstat (limited to 'pkg/gui/commits_panel.go')
-rw-r--r-- | pkg/gui/commits_panel.go | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/pkg/gui/commits_panel.go b/pkg/gui/commits_panel.go index 5e0c18bfd..6be372f2e 100644 --- a/pkg/gui/commits_panel.go +++ b/pkg/gui/commits_panel.go @@ -233,12 +233,16 @@ func (gui *Gui) handleRenameCommit(g *gocui.Gui, v *gocui.View) error { return gui.surfaceError(err) } - return gui.prompt(gui.Tr.LcRenameCommit, message, func(response string) error { - if err := gui.GitCommand.RenameCommit(response); err != nil { - return gui.surfaceError(err) - } + return gui.prompt(promptOpts{ + title: gui.Tr.LcRenameCommit, + initialContent: message, + handleConfirm: func(response string) error { + if err := gui.GitCommand.RenameCommit(response); err != nil { + return gui.surfaceError(err) + } - return gui.refreshSidePanels(refreshOptions{mode: ASYNC}) + return gui.refreshSidePanels(refreshOptions{mode: ASYNC}) + }, }) } @@ -517,11 +521,14 @@ func (gui *Gui) handleTagCommit(g *gocui.Gui, v *gocui.View) error { } func (gui *Gui) handleCreateLightweightTag(commitSha string) error { - return gui.prompt(gui.Tr.TagNameTitle, "", func(response string) error { - if err := gui.GitCommand.CreateLightweightTag(response, commitSha); err != nil { - return gui.surfaceError(err) - } - return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{COMMITS, TAGS}}) + return gui.prompt(promptOpts{ + title: gui.Tr.TagNameTitle, + handleConfirm: func(response string) error { + if err := gui.GitCommand.CreateLightweightTag(response, commitSha); err != nil { + return gui.surfaceError(err) + } + return gui.refreshSidePanels(refreshOptions{mode: ASYNC, scope: []int{COMMITS, TAGS}}) + }, }) } |