diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-17 12:07:36 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2019-11-21 22:07:14 +1100 |
commit | 55ff0c0dee09b505ecd123f3f893e143651947bf (patch) | |
tree | e9df2f62c6ce3e49a80517d65cd07207c7f8edb4 /pkg/gui | |
parent | 6b7aaeca45847ebc41aa0fd9b773362d4a79f1ab (diff) |
support detached heads when showing the selected branch
Diffstat (limited to 'pkg/gui')
-rw-r--r-- | pkg/gui/keybindings.go | 8 | ||||
-rw-r--r-- | pkg/gui/remote_branches_panel.go | 11 |
2 files changed, 19 insertions, 0 deletions
diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index eb817e76d..b74281df7 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -1058,6 +1058,14 @@ func (gui *Gui) GetInitialKeybindings() []*Binding { Description: gui.Tr.SLocalize("removeRemote"), }, { + ViewName: "branches", + Contexts: []string{"remote-branches"}, + Key: gocui.KeySpace, + Modifier: gocui.ModNone, + Handler: gui.handleCheckoutRemoteBranch, + Description: gui.Tr.SLocalize("checkout"), + }, + { ViewName: "commits", Key: gocui.MouseLeft, Modifier: gocui.ModNone, diff --git a/pkg/gui/remote_branches_panel.go b/pkg/gui/remote_branches_panel.go index f47ea9f63..771a7a9ad 100644 --- a/pkg/gui/remote_branches_panel.go +++ b/pkg/gui/remote_branches_panel.go @@ -81,3 +81,14 @@ func (gui *Gui) renderRemoteBranchesWithSelection() error { return nil } + +func (gui *Gui) handleCheckoutRemoteBranch(g *gocui.Gui, v *gocui.View) error { + remoteBranch := gui.getSelectedRemoteBranch() + if remoteBranch == nil { + return nil + } + if err := gui.handleCheckoutBranch(remoteBranch.RemoteName + "/" + remoteBranch.Name); err != nil { + return err + } + return gui.switchBranchesPanelContext("local-branches") +} |