diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-05-30 22:45:56 +1000 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-06-06 20:50:19 +1000 |
commit | 0f0fda16605059ebae73d29f0e4b9b5d1455ce73 (patch) | |
tree | 6d14bff955e00ee16f3170a0e0f80b7edc89d980 /pkg/gui/files_panel.go | |
parent | bd2170a99cb996f2e00467a3416645a85eaf0549 (diff) |
allow stashing staged changes
reinstate old stash functionality with the 's' keybinding
Diffstat (limited to 'pkg/gui/files_panel.go')
-rw-r--r-- | pkg/gui/files_panel.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go index 3d2001ac1..043c6ceab 100644 --- a/pkg/gui/files_panel.go +++ b/pkg/gui/files_panel.go @@ -627,3 +627,46 @@ func (gui *Gui) handleCustomCommand(g *gocui.Gui, v *gocui.View) error { return gui.Errors.ErrSubProcess }) } + +type stashOption struct { + description string + handler func() error +} + +// GetDisplayStrings is a function. +func (o *stashOption) GetDisplayStrings(isFocused bool) []string { + return []string{o.description} +} + +func (gui *Gui) handleCreateStashMenu(g *gocui.Gui, v *gocui.View) error { + options := []*stashOption{ + { + description: gui.Tr.SLocalize("stashAllChanges"), + handler: func() error { + return gui.handleStashSave(gui.GitCommand.StashSave) + }, + }, + { + description: gui.Tr.SLocalize("stashStagedChanges"), + handler: func() error { + return gui.handleStashSave(gui.GitCommand.StashSaveStagedChanges) + }, + }, + { + description: gui.Tr.SLocalize("cancel"), + handler: func() error { + return nil + }, + }, + } + + handleMenuPress := func(index int) error { + return options[index].handler() + } + + return gui.createMenu(gui.Tr.SLocalize("stashOptions"), options, len(options), handleMenuPress) +} + +func (gui *Gui) handleStashChanges(g *gocui.Gui, v *gocui.View) error { + return gui.handleStashSave(gui.GitCommand.StashSave) +} |