mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-17 00:18:05 +02:00
Remove return value of IContextMgr.Push/Pop et. al.
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
package gui
|
package gui
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
"github.com/jesseduffield/lazygit/pkg/gui/context"
|
||||||
@ -37,9 +36,9 @@ func NewContextMgr(
|
|||||||
|
|
||||||
// use when you don't want to return to the original context upon
|
// use when you don't want to return to the original context upon
|
||||||
// hitting escape: you want to go that context's parent instead.
|
// hitting escape: you want to go that context's parent instead.
|
||||||
func (self *ContextMgr) Replace(c types.Context) error {
|
func (self *ContextMgr) Replace(c types.Context) {
|
||||||
if !c.IsFocusable() {
|
if !c.IsFocusable() {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
self.Lock()
|
self.Lock()
|
||||||
@ -53,12 +52,12 @@ func (self *ContextMgr) Replace(c types.Context) error {
|
|||||||
|
|
||||||
self.Unlock()
|
self.Unlock()
|
||||||
|
|
||||||
return self.Activate(c, types.OnFocusOpts{})
|
self.Activate(c, types.OnFocusOpts{})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ContextMgr) Push(c types.Context, opts ...types.OnFocusOpts) error {
|
func (self *ContextMgr) Push(c types.Context, opts ...types.OnFocusOpts) {
|
||||||
if len(opts) > 1 {
|
if len(opts) > 1 {
|
||||||
return errors.New("cannot pass multiple opts to Push")
|
panic("cannot pass multiple opts to Push")
|
||||||
}
|
}
|
||||||
|
|
||||||
singleOpts := types.OnFocusOpts{}
|
singleOpts := types.OnFocusOpts{}
|
||||||
@ -68,22 +67,18 @@ func (self *ContextMgr) Push(c types.Context, opts ...types.OnFocusOpts) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !c.IsFocusable() {
|
if !c.IsFocusable() {
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
contextsToDeactivate, contextToActivate := self.pushToContextStack(c)
|
contextsToDeactivate, contextToActivate := self.pushToContextStack(c)
|
||||||
|
|
||||||
for _, contextToDeactivate := range contextsToDeactivate {
|
for _, contextToDeactivate := range contextsToDeactivate {
|
||||||
if err := self.deactivate(contextToDeactivate, types.OnFocusLostOpts{NewContextKey: c.GetKey()}); err != nil {
|
self.deactivate(contextToDeactivate, types.OnFocusLostOpts{NewContextKey: c.GetKey()})
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if contextToActivate == nil {
|
if contextToActivate != nil {
|
||||||
return nil
|
self.Activate(contextToActivate, singleOpts)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.Activate(contextToActivate, singleOpts)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjusts the context stack based on the context that's being pushed and
|
// Adjusts the context stack based on the context that's being pushed and
|
||||||
@ -144,13 +139,13 @@ func (self *ContextMgr) pushToContextStack(c types.Context) ([]types.Context, ty
|
|||||||
return contextsToDeactivate, c
|
return contextsToDeactivate, c
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ContextMgr) Pop() error {
|
func (self *ContextMgr) Pop() {
|
||||||
self.Lock()
|
self.Lock()
|
||||||
|
|
||||||
if len(self.ContextStack) == 1 {
|
if len(self.ContextStack) == 1 {
|
||||||
// cannot escape from bottommost context
|
// cannot escape from bottommost context
|
||||||
self.Unlock()
|
self.Unlock()
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentContext types.Context
|
var currentContext types.Context
|
||||||
@ -160,14 +155,12 @@ func (self *ContextMgr) Pop() error {
|
|||||||
|
|
||||||
self.Unlock()
|
self.Unlock()
|
||||||
|
|
||||||
if err := self.deactivate(currentContext, types.OnFocusLostOpts{NewContextKey: newContext.GetKey()}); err != nil {
|
self.deactivate(currentContext, types.OnFocusLostOpts{NewContextKey: newContext.GetKey()})
|
||||||
return err
|
|
||||||
|
self.Activate(newContext, types.OnFocusOpts{})
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.Activate(newContext, types.OnFocusOpts{})
|
func (self *ContextMgr) deactivate(c types.Context, opts types.OnFocusLostOpts) {
|
||||||
}
|
|
||||||
|
|
||||||
func (self *ContextMgr) deactivate(c types.Context, opts types.OnFocusLostOpts) error {
|
|
||||||
view, _ := self.gui.c.GocuiGui().View(c.GetViewName())
|
view, _ := self.gui.c.GocuiGui().View(c.GetViewName())
|
||||||
|
|
||||||
if opts.NewContextKey != context.SEARCH_CONTEXT_KEY {
|
if opts.NewContextKey != context.SEARCH_CONTEXT_KEY {
|
||||||
@ -184,15 +177,13 @@ func (self *ContextMgr) deactivate(c types.Context, opts types.OnFocusLostOpts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.HandleFocusLost(opts)
|
c.HandleFocusLost(opts)
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ContextMgr) Activate(c types.Context, opts types.OnFocusOpts) error {
|
func (self *ContextMgr) Activate(c types.Context, opts types.OnFocusOpts) {
|
||||||
viewName := c.GetViewName()
|
viewName := c.GetViewName()
|
||||||
v, err := self.gui.c.GocuiGui().View(viewName)
|
v, err := self.gui.c.GocuiGui().View(viewName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.gui.helpers.Window.SetWindowContext(c)
|
self.gui.helpers.Window.SetWindowContext(c)
|
||||||
@ -203,7 +194,7 @@ func (self *ContextMgr) Activate(c types.Context, opts types.OnFocusOpts) error
|
|||||||
oldView.HighlightInactive = true
|
oldView.HighlightInactive = true
|
||||||
}
|
}
|
||||||
if _, err := self.gui.c.GocuiGui().SetCurrentView(viewName); err != nil {
|
if _, err := self.gui.c.GocuiGui().SetCurrentView(viewName); err != nil {
|
||||||
return err
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.gui.helpers.Search.RenderSearchStatus(c)
|
self.gui.helpers.Search.RenderSearchStatus(c)
|
||||||
@ -218,8 +209,6 @@ func (self *ContextMgr) Activate(c types.Context, opts types.OnFocusOpts) error
|
|||||||
self.gui.c.GocuiGui().Cursor = v.Editable
|
self.gui.c.GocuiGui().Cursor = v.Editable
|
||||||
|
|
||||||
c.HandleFocus(opts)
|
c.HandleFocus(opts)
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *ContextMgr) Current() types.Context {
|
func (self *ContextMgr) Current() types.Context {
|
||||||
|
@ -197,9 +197,7 @@ func (self *MenuContext) OnMenuPress(selectedItem *types.MenuItem) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.c.Context().Pop(); err != nil {
|
self.c.Context().Pop()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if selectedItem == nil {
|
if selectedItem == nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -60,11 +60,13 @@ func (self *CommitDescriptionController) GetMouseKeybindings(opts types.Keybindi
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitDescriptionController) switchToCommitMessage() error {
|
func (self *CommitDescriptionController) switchToCommitMessage() error {
|
||||||
return self.c.Context().Replace(self.c.Contexts().CommitMessage)
|
self.c.Context().Replace(self.c.Contexts().CommitMessage)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitDescriptionController) close() error {
|
func (self *CommitDescriptionController) close() error {
|
||||||
return self.c.Helpers().Commits.CloseCommitMessagePanel()
|
self.c.Helpers().Commits.CloseCommitMessagePanel()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitDescriptionController) confirm() error {
|
func (self *CommitDescriptionController) confirm() error {
|
||||||
@ -79,7 +81,7 @@ func (self *CommitDescriptionController) openCommitMenu() error {
|
|||||||
func (self *CommitDescriptionController) onClick(opts gocui.ViewMouseBindingOpts) error {
|
func (self *CommitDescriptionController) onClick(opts gocui.ViewMouseBindingOpts) error {
|
||||||
// Activate the description panel when the commit message panel is currently active
|
// Activate the description panel when the commit message panel is currently active
|
||||||
if self.c.Context().Current().GetKey() == context.COMMIT_MESSAGE_CONTEXT_KEY {
|
if self.c.Context().Current().GetKey() == context.COMMIT_MESSAGE_CONTEXT_KEY {
|
||||||
return self.c.Context().Replace(self.c.Contexts().CommitDescription)
|
self.c.Context().Replace(self.c.Contexts().CommitDescription)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -95,9 +95,7 @@ func (self *CommitMessageController) handleNextCommit() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitMessageController) switchToCommitDescription() error {
|
func (self *CommitMessageController) switchToCommitDescription() error {
|
||||||
if err := self.c.Context().Replace(self.c.Contexts().CommitDescription); err != nil {
|
self.c.Context().Replace(self.c.Contexts().CommitDescription)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +138,8 @@ func (self *CommitMessageController) confirm() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitMessageController) close() error {
|
func (self *CommitMessageController) close() error {
|
||||||
return self.c.Helpers().Commits.CloseCommitMessagePanel()
|
self.c.Helpers().Commits.CloseCommitMessagePanel()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitMessageController) openCommitMenu() error {
|
func (self *CommitMessageController) openCommitMenu() error {
|
||||||
@ -151,7 +150,7 @@ func (self *CommitMessageController) openCommitMenu() error {
|
|||||||
func (self *CommitMessageController) onClick(opts gocui.ViewMouseBindingOpts) error {
|
func (self *CommitMessageController) onClick(opts gocui.ViewMouseBindingOpts) error {
|
||||||
// Activate the commit message panel when the commit description panel is currently active
|
// Activate the commit message panel when the commit description panel is currently active
|
||||||
if self.c.Context().Current().GetKey() == context.COMMIT_DESCRIPTION_CONTEXT_KEY {
|
if self.c.Context().Current().GetKey() == context.COMMIT_DESCRIPTION_CONTEXT_KEY {
|
||||||
return self.c.Context().Replace(self.c.Contexts().CommitMessage)
|
self.c.Context().Replace(self.c.Contexts().CommitMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -359,7 +359,8 @@ func (self *CommitFilesController) enterCommitFile(node *filetree.CommitFileNode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Context().Push(self.c.Contexts().CustomPatchBuilder, opts)
|
self.c.Context().Push(self.c.Contexts().CustomPatchBuilder, opts)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
from, to, reverse := self.currentFromToReverseForPatchBuilding()
|
from, to, reverse := self.currentFromToReverseForPatchBuilding()
|
||||||
|
@ -49,7 +49,7 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [
|
|||||||
self.c.UserConfig().Keybinding.Universal.Remove, self.c.UserConfig().Keybinding.Universal.Edit)
|
self.c.UserConfig().Keybinding.Universal.Remove, self.c.UserConfig().Keybinding.Universal.Edit)
|
||||||
}
|
}
|
||||||
self.c.Views().Suggestions.Subtitle = subtitle
|
self.c.Views().Suggestions.Subtitle = subtitle
|
||||||
return self.c.Context().Replace(self.c.Contexts().Suggestions)
|
self.c.Context().Replace(self.c.Contexts().Suggestions)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
|
@ -121,11 +121,10 @@ func (self *CustomPatchOptionsMenuAction) validateNormalWorkingTreeState() (bool
|
|||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CustomPatchOptionsMenuAction) returnFocusFromPatchExplorerIfNecessary() error {
|
func (self *CustomPatchOptionsMenuAction) returnFocusFromPatchExplorerIfNecessary() {
|
||||||
if self.c.Context().Current().GetKey() == self.c.Contexts().CustomPatchBuilder.GetKey() {
|
if self.c.Context().Current().GetKey() == self.c.Contexts().CustomPatchBuilder.GetKey() {
|
||||||
return self.c.Helpers().PatchBuilding.Escape()
|
self.c.Helpers().PatchBuilding.Escape()
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CustomPatchOptionsMenuAction) handleDeletePatchFromCommit() error {
|
func (self *CustomPatchOptionsMenuAction) handleDeletePatchFromCommit() error {
|
||||||
@ -133,9 +132,7 @@ func (self *CustomPatchOptionsMenuAction) handleDeletePatchFromCommit() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.returnFocusFromPatchExplorerIfNecessary(); err != nil {
|
self.returnFocusFromPatchExplorerIfNecessary()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error {
|
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error {
|
||||||
commitIndex := self.getPatchCommitIndex()
|
commitIndex := self.getPatchCommitIndex()
|
||||||
@ -150,9 +147,7 @@ func (self *CustomPatchOptionsMenuAction) handleMovePatchToSelectedCommit() erro
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.returnFocusFromPatchExplorerIfNecessary(); err != nil {
|
self.returnFocusFromPatchExplorerIfNecessary()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error {
|
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error {
|
||||||
commitIndex := self.getPatchCommitIndex()
|
commitIndex := self.getPatchCommitIndex()
|
||||||
@ -167,9 +162,7 @@ func (self *CustomPatchOptionsMenuAction) handleMovePatchIntoWorkingTree() error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.returnFocusFromPatchExplorerIfNecessary(); err != nil {
|
self.returnFocusFromPatchExplorerIfNecessary()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
pull := func(stash bool) error {
|
pull := func(stash bool) error {
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error {
|
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error {
|
||||||
@ -198,9 +191,7 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.returnFocusFromPatchExplorerIfNecessary(); err != nil {
|
self.returnFocusFromPatchExplorerIfNecessary()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
commitIndex := self.getPatchCommitIndex()
|
commitIndex := self.getPatchCommitIndex()
|
||||||
return self.c.Helpers().Commits.OpenCommitMessagePanel(
|
return self.c.Helpers().Commits.OpenCommitMessagePanel(
|
||||||
@ -214,13 +205,14 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error {
|
|||||||
PreserveMessage: false,
|
PreserveMessage: false,
|
||||||
OnConfirm: func(summary string, description string) error {
|
OnConfirm: func(summary string, description string) error {
|
||||||
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error {
|
return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error {
|
||||||
_ = self.c.Helpers().Commits.CloseCommitMessagePanel()
|
self.c.Helpers().Commits.CloseCommitMessagePanel()
|
||||||
self.c.LogAction(self.c.Tr.Actions.MovePatchIntoNewCommit)
|
self.c.LogAction(self.c.Tr.Actions.MovePatchIntoNewCommit)
|
||||||
err := self.c.Git().Patch.PullPatchIntoNewCommit(self.c.Model().Commits, commitIndex, summary, description)
|
err := self.c.Git().Patch.PullPatchIntoNewCommit(self.c.Model().Commits, commitIndex, summary, description)
|
||||||
if err := self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err); err != nil {
|
if err := self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return self.c.Context().Push(self.c.Contexts().LocalCommits)
|
self.c.Context().Push(self.c.Contexts().LocalCommits)
|
||||||
|
return nil
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -228,9 +220,7 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *CustomPatchOptionsMenuAction) handleApplyPatch(reverse bool) error {
|
func (self *CustomPatchOptionsMenuAction) handleApplyPatch(reverse bool) error {
|
||||||
if err := self.returnFocusFromPatchExplorerIfNecessary(); err != nil {
|
self.returnFocusFromPatchExplorerIfNecessary()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
action := self.c.Tr.Actions.ApplyPatch
|
action := self.c.Tr.Actions.ApplyPatch
|
||||||
if reverse {
|
if reverse {
|
||||||
|
@ -505,7 +505,8 @@ func (self *FilesController) EnterFile(opts types.OnFocusOpts) error {
|
|||||||
return errors.New(self.c.Tr.FileStagingRequirements)
|
return errors.New(self.c.Tr.FileStagingRequirements)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Context().Push(self.c.Contexts().Staging, opts)
|
self.c.Context().Push(self.c.Contexts().Staging, opts)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *FilesController) toggleStagedAll() error {
|
func (self *FilesController) toggleStagedAll() error {
|
||||||
|
@ -116,9 +116,7 @@ func (self *FilteringMenuAction) setFiltering() error {
|
|||||||
repoState.SetScreenMode(types.SCREEN_HALF)
|
repoState.SetScreenMode(types.SCREEN_HALF)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.c.Context().Push(self.c.Contexts().LocalCommits); err != nil {
|
self.c.Context().Push(self.c.Contexts().LocalCommits)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() error {
|
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() error {
|
||||||
self.c.Contexts().LocalCommits.SetSelection(0)
|
self.c.Contexts().LocalCommits.SetSelection(0)
|
||||||
|
@ -101,10 +101,7 @@ func (self *CommitsHelper) SwitchToEditor() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = self.CloseCommitMessagePanel()
|
self.CloseCommitMessagePanel()
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.c.Contexts().CommitMessage.SwitchToEditor(filepath)
|
return self.c.Contexts().CommitMessage.SwitchToEditor(filepath)
|
||||||
}
|
}
|
||||||
@ -136,9 +133,7 @@ type OpenCommitMessagePanelOpts struct {
|
|||||||
|
|
||||||
func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOpts) error {
|
func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOpts) error {
|
||||||
onConfirm := func(summary string, description string) error {
|
onConfirm := func(summary string, description string) error {
|
||||||
if err := self.CloseCommitMessagePanel(); err != nil {
|
self.CloseCommitMessagePanel()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return opts.OnConfirm(summary, description)
|
return opts.OnConfirm(summary, description)
|
||||||
}
|
}
|
||||||
@ -154,7 +149,8 @@ func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOp
|
|||||||
|
|
||||||
self.UpdateCommitPanelView(opts.InitialMessage)
|
self.UpdateCommitPanelView(opts.InitialMessage)
|
||||||
|
|
||||||
return self.c.Context().Push(self.c.Contexts().CommitMessage)
|
self.c.Context().Push(self.c.Contexts().CommitMessage)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitsHelper) OnCommitSuccess() {
|
func (self *CommitsHelper) OnCommitSuccess() {
|
||||||
@ -179,7 +175,7 @@ func (self *CommitsHelper) HandleCommitConfirm() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitsHelper) CloseCommitMessagePanel() error {
|
func (self *CommitsHelper) CloseCommitMessagePanel() {
|
||||||
if self.c.Contexts().CommitMessage.GetPreserveMessage() {
|
if self.c.Contexts().CommitMessage.GetPreserveMessage() {
|
||||||
message := self.JoinCommitMessageAndUnwrappedDescription()
|
message := self.JoinCommitMessageAndUnwrappedDescription()
|
||||||
|
|
||||||
@ -193,7 +189,7 @@ func (self *CommitsHelper) CloseCommitMessagePanel() error {
|
|||||||
self.c.Views().CommitMessage.Visible = false
|
self.c.Views().CommitMessage.Visible = false
|
||||||
self.c.Views().CommitDescription.Visible = false
|
self.c.Views().CommitDescription.Visible = false
|
||||||
|
|
||||||
return self.c.Context().Pop()
|
self.c.Context().Pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.Suggestion) error {
|
func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.Suggestion) error {
|
||||||
|
@ -28,9 +28,7 @@ func (self *ConfirmationHelper) wrappedConfirmationFunction(cancel goContext.Can
|
|||||||
return func() error {
|
return func() error {
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
if err := self.c.Context().Pop(); err != nil {
|
self.c.Context().Pop()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if function != nil {
|
if function != nil {
|
||||||
if err := function(); err != nil {
|
if err := function(); err != nil {
|
||||||
@ -232,7 +230,8 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ
|
|||||||
|
|
||||||
self.c.State().GetRepoState().SetCurrentPopupOpts(&opts)
|
self.c.State().GetRepoState().SetCurrentPopupOpts(&opts)
|
||||||
|
|
||||||
return self.c.Context().Push(self.c.Contexts().Confirmation)
|
self.c.Context().Push(self.c.Contexts().Confirmation)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func underlineLinks(text string) string {
|
func underlineLinks(text string) string {
|
||||||
|
@ -137,7 +137,8 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.c.Contexts().LocalCommits.SetSelection(index)
|
self.c.Contexts().LocalCommits.SetSelection(index)
|
||||||
return self.c.Context().Push(self.c.Contexts().LocalCommits)
|
self.c.Context().Push(self.c.Contexts().LocalCommits)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if warnAboutAddedLines {
|
if warnAboutAddedLines {
|
||||||
|
@ -202,7 +202,8 @@ func (self *MergeAndRebaseHelper) PromptForConflictHandling() error {
|
|||||||
{
|
{
|
||||||
Label: self.c.Tr.ViewConflictsMenuItem,
|
Label: self.c.Tr.ViewConflictsMenuItem,
|
||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
return self.c.Context().Push(self.c.Contexts().Files)
|
self.c.Context().Push(self.c.Contexts().Files)
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -346,7 +347,8 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error {
|
|||||||
if err = self.ResetMarkedBaseCommit(); err != nil {
|
if err = self.ResetMarkedBaseCommit(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return self.c.Context().Push(self.c.Contexts().LocalCommits)
|
self.c.Context().Push(self.c.Contexts().LocalCommits)
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,7 @@ func (self *MergeConflictsHelper) EscapeMerge() error {
|
|||||||
// files context over it.
|
// files context over it.
|
||||||
// So long as both places call OnUIThread, we're fine.
|
// So long as both places call OnUIThread, we're fine.
|
||||||
if self.c.Context().IsCurrent(self.c.Contexts().MergeConflicts) {
|
if self.c.Context().IsCurrent(self.c.Contexts().MergeConflicts) {
|
||||||
return self.c.Context().Push(self.c.Contexts().Files)
|
self.c.Context().Push(self.c.Contexts().Files)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@ -93,7 +93,8 @@ func (self *MergeConflictsHelper) SwitchToMerge(path string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Context().Push(self.c.Contexts().MergeConflicts)
|
self.c.Context().Push(self.c.Contexts().MergeConflicts)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MergeConflictsHelper) context() *context.MergeConflictsContext {
|
func (self *MergeConflictsHelper) context() *context.MergeConflictsContext {
|
||||||
|
@ -33,8 +33,8 @@ func (self *PatchBuildingHelper) ValidateNormalWorkingTreeState() (bool, error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// takes us from the patch building panel back to the commit files panel
|
// takes us from the patch building panel back to the commit files panel
|
||||||
func (self *PatchBuildingHelper) Escape() error {
|
func (self *PatchBuildingHelper) Escape() {
|
||||||
return self.c.Context().Pop()
|
self.c.Context().Pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
// kills the custom patch and returns us back to the commit files panel if needed
|
// kills the custom patch and returns us back to the commit files panel if needed
|
||||||
@ -42,9 +42,7 @@ func (self *PatchBuildingHelper) Reset() error {
|
|||||||
self.c.Git().Patch.PatchBuilder.Reset()
|
self.c.Git().Patch.PatchBuilder.Reset()
|
||||||
|
|
||||||
if self.c.Context().CurrentStatic().GetKind() != types.SIDE_CONTEXT {
|
if self.c.Context().CurrentStatic().GetKind() != types.SIDE_CONTEXT {
|
||||||
if err := self.Escape(); err != nil {
|
self.Escape()
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.c.Refresh(types.RefreshOptions{
|
if err := self.c.Refresh(types.RefreshOptions{
|
||||||
@ -64,7 +62,8 @@ func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpt
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !self.c.Git().Patch.PatchBuilder.Active() {
|
if !self.c.Git().Patch.PatchBuilder.Active() {
|
||||||
return self.Escape()
|
self.Escape()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// get diff from commit file that's currently selected
|
// get diff from commit file that's currently selected
|
||||||
@ -94,7 +93,8 @@ func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpt
|
|||||||
state := patch_exploring.NewState(diff, selectedLineIdx, oldState, self.c.Log)
|
state := patch_exploring.NewState(diff, selectedLineIdx, oldState, self.c.Log)
|
||||||
context.SetState(state)
|
context.SetState(state)
|
||||||
if state == nil {
|
if state == nil {
|
||||||
return self.Escape()
|
self.Escape()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
mainContent := context.GetContentToRender(true)
|
mainContent := context.GetContentToRender(true)
|
||||||
|
@ -115,9 +115,7 @@ func (self *RefsHelper) CheckoutRemoteBranch(fullBranchName string, localBranchN
|
|||||||
// Switch to the branches context _before_ starting to check out the
|
// Switch to the branches context _before_ starting to check out the
|
||||||
// branch, so that we see the inline status
|
// branch, so that we see the inline status
|
||||||
if self.c.Context().Current() != self.c.Contexts().Branches {
|
if self.c.Context().Current() != self.c.Contexts().Branches {
|
||||||
if err := self.c.Context().Push(self.c.Contexts().Branches); err != nil {
|
self.c.Context().Push(self.c.Contexts().Branches)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return self.CheckoutRef(branchName, types.CheckoutRefOptions{})
|
return self.CheckoutRef(branchName, types.CheckoutRefOptions{})
|
||||||
}
|
}
|
||||||
@ -285,9 +283,7 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest
|
|||||||
|
|
||||||
refresh := func() error {
|
refresh := func() error {
|
||||||
if self.c.Context().Current() != self.c.Contexts().Branches {
|
if self.c.Context().Current() != self.c.Contexts().Branches {
|
||||||
if err := self.c.Context().Push(self.c.Contexts().Branches); err != nil {
|
self.c.Context().Push(self.c.Contexts().Branches)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self.c.Contexts().LocalCommits.SetSelection(0)
|
self.c.Contexts().LocalCommits.SetSelection(0)
|
||||||
|
@ -41,9 +41,7 @@ func (self *SearchHelper) OpenFilterPrompt(context types.IFilterableContext) err
|
|||||||
self.OnPromptContentChanged("")
|
self.OnPromptContentChanged("")
|
||||||
promptView.RenderTextArea()
|
promptView.RenderTextArea()
|
||||||
|
|
||||||
if err := self.c.Context().Push(self.c.Contexts().Search); err != nil {
|
self.c.Context().Push(self.c.Contexts().Search)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.c.ResetKeybindings()
|
return self.c.ResetKeybindings()
|
||||||
}
|
}
|
||||||
@ -60,9 +58,7 @@ func (self *SearchHelper) OpenSearchPrompt(context types.ISearchableContext) err
|
|||||||
promptView.ClearTextArea()
|
promptView.ClearTextArea()
|
||||||
promptView.RenderTextArea()
|
promptView.RenderTextArea()
|
||||||
|
|
||||||
if err := self.c.Context().Push(self.c.Contexts().Search); err != nil {
|
self.c.Context().Push(self.c.Contexts().Search)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.c.ResetKeybindings()
|
return self.c.ResetKeybindings()
|
||||||
}
|
}
|
||||||
@ -115,11 +111,11 @@ func (self *SearchHelper) Confirm() error {
|
|||||||
var err error
|
var err error
|
||||||
switch state.SearchType() {
|
switch state.SearchType() {
|
||||||
case types.SearchTypeFilter:
|
case types.SearchTypeFilter:
|
||||||
err = self.ConfirmFilter()
|
self.ConfirmFilter()
|
||||||
case types.SearchTypeSearch:
|
case types.SearchTypeSearch:
|
||||||
err = self.ConfirmSearch()
|
err = self.ConfirmSearch()
|
||||||
case types.SearchTypeNone:
|
case types.SearchTypeNone:
|
||||||
err = self.c.Context().Pop()
|
self.c.Context().Pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -129,14 +125,14 @@ func (self *SearchHelper) Confirm() error {
|
|||||||
return self.c.ResetKeybindings()
|
return self.c.ResetKeybindings()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *SearchHelper) ConfirmFilter() error {
|
func (self *SearchHelper) ConfirmFilter() {
|
||||||
// We also do this on each keypress but we do it here again just in case
|
// We also do this on each keypress but we do it here again just in case
|
||||||
state := self.searchState()
|
state := self.searchState()
|
||||||
|
|
||||||
context, ok := state.Context.(types.IFilterableContext)
|
context, ok := state.Context.(types.IFilterableContext)
|
||||||
if !ok {
|
if !ok {
|
||||||
self.c.Log.Warnf("Context %s is not filterable", state.Context.GetKey())
|
self.c.Log.Warnf("Context %s is not filterable", state.Context.GetKey())
|
||||||
return nil
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
self.OnPromptContentChanged(self.promptContent())
|
self.OnPromptContentChanged(self.promptContent())
|
||||||
@ -145,7 +141,7 @@ func (self *SearchHelper) ConfirmFilter() error {
|
|||||||
context.GetSearchHistory().Push(filterString)
|
context.GetSearchHistory().Push(filterString)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Context().Pop()
|
self.c.Context().Pop()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *SearchHelper) ConfirmSearch() error {
|
func (self *SearchHelper) ConfirmSearch() error {
|
||||||
@ -163,9 +159,7 @@ func (self *SearchHelper) ConfirmSearch() error {
|
|||||||
context.GetSearchHistory().Push(searchString)
|
context.GetSearchHistory().Push(searchString)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.c.Context().Pop(); err != nil {
|
self.c.Context().Pop()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return context.GetView().Search(searchString, modelSearchResults(context))
|
return context.GetView().Search(searchString, modelSearchResults(context))
|
||||||
}
|
}
|
||||||
@ -188,9 +182,7 @@ func modelSearchResults(context types.ISearchableContext) []gocui.SearchPosition
|
|||||||
func (self *SearchHelper) CancelPrompt() error {
|
func (self *SearchHelper) CancelPrompt() error {
|
||||||
self.Cancel()
|
self.Cancel()
|
||||||
|
|
||||||
if err := self.c.Context().Pop(); err != nil {
|
self.c.Context().Pop()
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return self.c.ResetKeybindings()
|
return self.c.ResetKeybindings()
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if file == nil || (!file.HasUnstagedChanges && !file.HasStagedChanges) {
|
if file == nil || (!file.HasUnstagedChanges && !file.HasStagedChanges) {
|
||||||
_ = self.handleStagingEscape()
|
self.handleStagingEscape()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,17 +80,17 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) {
|
|||||||
secondaryContext.GetMutex().Unlock()
|
secondaryContext.GetMutex().Unlock()
|
||||||
|
|
||||||
if mainState == nil && secondaryState == nil {
|
if mainState == nil && secondaryState == nil {
|
||||||
_ = self.handleStagingEscape()
|
self.handleStagingEscape()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if mainState == nil && !secondaryFocused {
|
if mainState == nil && !secondaryFocused {
|
||||||
_ = self.c.Context().Push(secondaryContext, focusOpts)
|
self.c.Context().Push(secondaryContext, focusOpts)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if secondaryState == nil && secondaryFocused {
|
if secondaryState == nil && secondaryFocused {
|
||||||
_ = self.c.Context().Push(mainContext, focusOpts)
|
self.c.Context().Push(mainContext, focusOpts)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,8 +113,8 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StagingHelper) handleStagingEscape() error {
|
func (self *StagingHelper) handleStagingEscape() {
|
||||||
return self.c.Context().Push(self.c.Contexts().Files)
|
self.c.Context().Push(self.c.Contexts().Files)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StagingHelper) secondaryStagingFocused() bool {
|
func (self *StagingHelper) secondaryStagingFocused() bool {
|
||||||
|
@ -72,5 +72,6 @@ func (self *SubCommitsHelper) ViewSubCommits(opts ViewSubCommitsOpts) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Context().Push(self.c.Contexts().SubCommits)
|
self.c.Context().Push(self.c.Contexts().SubCommits)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ func (self *JumpToSideWindowController) goToSideWindow(window string) func() err
|
|||||||
|
|
||||||
context := self.c.Helpers().Window.GetContextForWindow(window)
|
context := self.c.Helpers().Window.GetContextForWindow(window)
|
||||||
|
|
||||||
return self.c.Context().Push(context)
|
self.c.Context().Push(context)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,9 +179,7 @@ func (self *ListController) HandleClick(opts gocui.ViewMouseBindingOpts) error {
|
|||||||
|
|
||||||
func (self *ListController) pushContextIfNotFocused() error {
|
func (self *ListController) pushContextIfNotFocused() error {
|
||||||
if !self.isFocused() {
|
if !self.isFocused() {
|
||||||
if err := self.c.Context().Push(self.context); err != nil {
|
self.c.Context().Push(self.context)
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -78,7 +78,8 @@ func (self *MenuController) close() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Context().Pop()
|
self.c.Context().Pop()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MenuController) context() *context.MenuContext {
|
func (self *MenuController) context() *context.MenuContext {
|
||||||
|
@ -188,7 +188,8 @@ func (self *MergeConflictsController) context() *context.MergeConflictsContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *MergeConflictsController) Escape() error {
|
func (self *MergeConflictsController) Escape() error {
|
||||||
return self.c.Context().Pop()
|
self.c.Context().Pop()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *MergeConflictsController) HandleEditFile() error {
|
func (self *MergeConflictsController) HandleEditFile() error {
|
||||||
|
@ -165,5 +165,6 @@ func (self *PatchBuildingController) Escape() error {
|
|||||||
return self.c.PostRefreshUpdate(context)
|
return self.c.PostRefreshUpdate(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Helpers().PatchBuilding.Escape()
|
self.c.Helpers().PatchBuilding.Escape()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -150,10 +150,12 @@ func (self *PatchExplorerController) GetMouseKeybindings(opts types.KeybindingsO
|
|||||||
return self.withRenderAndFocus(self.HandleMouseDown)()
|
return self.withRenderAndFocus(self.HandleMouseDown)()
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Context().Push(self.context, types.OnFocusOpts{
|
self.c.Context().Push(self.context, types.OnFocusOpts{
|
||||||
ClickedWindowName: self.context.GetWindowName(),
|
ClickedWindowName: self.context.GetWindowName(),
|
||||||
ClickedViewLineIdx: opts.Y,
|
ClickedViewLineIdx: opts.Y,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,8 @@ func (self *QuitActions) Escape() error {
|
|||||||
parentContext := currentContext.GetParentContext()
|
parentContext := currentContext.GetParentContext()
|
||||||
if parentContext != nil {
|
if parentContext != nil {
|
||||||
// TODO: think about whether this should be marked as a return rather than adding to the stack
|
// TODO: think about whether this should be marked as a return rather than adding to the stack
|
||||||
return self.c.Context().Push(parentContext)
|
self.c.Context().Push(parentContext)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, mode := range self.c.Helpers().Mode.Statuses() {
|
for _, mode := range self.c.Helpers().Mode.Statuses() {
|
||||||
|
@ -131,7 +131,8 @@ func (self *RemotesController) enter(remote *models.Remote) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Context().Push(remoteBranchesContext)
|
self.c.Context().Push(remoteBranchesContext)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *RemotesController) add() error {
|
func (self *RemotesController) add() error {
|
||||||
|
@ -69,7 +69,8 @@ func (self *SideWindowController) previousSideWindow() error {
|
|||||||
|
|
||||||
context := self.c.Helpers().Window.GetContextForWindow(newWindow)
|
context := self.c.Helpers().Window.GetContextForWindow(newWindow)
|
||||||
|
|
||||||
return self.c.Context().Push(context)
|
self.c.Context().Push(context)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *SideWindowController) nextSideWindow() error {
|
func (self *SideWindowController) nextSideWindow() error {
|
||||||
@ -92,5 +93,6 @@ func (self *SideWindowController) nextSideWindow() error {
|
|||||||
|
|
||||||
context := self.c.Helpers().Window.GetContextForWindow(newWindow)
|
context := self.c.Helpers().Window.GetContextForWindow(newWindow)
|
||||||
|
|
||||||
return self.c.Context().Push(context)
|
self.c.Context().Push(context)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -73,5 +73,6 @@ func (self *SnakeController) SetDirection(direction snake.Direction) func() erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *SnakeController) Escape() error {
|
func (self *SnakeController) Escape() error {
|
||||||
return self.c.Context().Push(self.c.Contexts().Submodules)
|
self.c.Context().Push(self.c.Contexts().Submodules)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -171,12 +171,13 @@ func (self *StagingController) Escape() error {
|
|||||||
return self.c.PostRefreshUpdate(self.context)
|
return self.c.PostRefreshUpdate(self.context)
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Context().Pop()
|
self.c.Context().Pop()
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *StagingController) TogglePanel() error {
|
func (self *StagingController) TogglePanel() error {
|
||||||
if self.otherContext.GetState() != nil {
|
if self.otherContext.GetState() != nil {
|
||||||
return self.c.Context().Push(self.otherContext)
|
self.c.Context().Push(self.otherContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -104,9 +104,7 @@ func (self *StatusController) onClick(opts gocui.ViewMouseBindingOpts) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := self.c.Context().Push(self.Context()); err != nil {
|
self.c.Context().Push(self.Context())
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
upstreamStatus := utils.Decolorise(presentation.BranchStatus(currentBranch, types.ItemOperationNone, self.c.Tr, time.Now(), self.c.UserConfig()))
|
upstreamStatus := utils.Decolorise(presentation.BranchStatus(currentBranch, types.ItemOperationNone, self.c.Tr, time.Now(), self.c.UserConfig()))
|
||||||
repoName := self.c.Git().RepoPaths.RepoName()
|
repoName := self.c.Git().RepoPaths.RepoName()
|
||||||
|
@ -285,7 +285,8 @@ func (self *SubmodulesController) remove(submodule *models.SubmoduleConfig) erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *SubmodulesController) easterEgg() error {
|
func (self *SubmodulesController) easterEgg() error {
|
||||||
return self.c.Context().Push(self.c.Contexts().Snake)
|
self.c.Context().Push(self.c.Contexts().Snake)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *SubmodulesController) context() *context.SubmodulesContext {
|
func (self *SubmodulesController) context() *context.SubmodulesContext {
|
||||||
|
@ -72,7 +72,8 @@ func (self *SuggestionsController) GetKeybindings(opts types.KeybindingsOpts) []
|
|||||||
func (self *SuggestionsController) switchToConfirmation() error {
|
func (self *SuggestionsController) switchToConfirmation() error {
|
||||||
self.c.Views().Suggestions.Subtitle = ""
|
self.c.Views().Suggestions.Subtitle = ""
|
||||||
self.c.Views().Suggestions.Highlight = false
|
self.c.Views().Suggestions.Highlight = false
|
||||||
return self.c.Context().Replace(self.c.Contexts().Confirmation)
|
self.c.Context().Replace(self.c.Contexts().Confirmation)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *SuggestionsController) GetOnFocusLost() func(types.OnFocusLostOpts) {
|
func (self *SuggestionsController) GetOnFocusLost() func(types.OnFocusLostOpts) {
|
||||||
|
@ -91,7 +91,8 @@ func (self *SwitchToDiffFilesController) enter() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.c.Context().Push(commitFilesContext)
|
self.c.Context().Push(commitFilesContext)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *SwitchToDiffFilesController) canEnter() *types.DisabledReason {
|
func (self *SwitchToDiffFilesController) canEnter() *types.DisabledReason {
|
||||||
|
@ -115,7 +115,8 @@ func (self *TagsController) checkout(tag *models.Tag) error {
|
|||||||
if err := self.c.Helpers().Refs.CheckoutRef(tag.FullRefName(), types.CheckoutRefOptions{}); err != nil {
|
if err := self.c.Helpers().Refs.CheckoutRef(tag.FullRefName(), types.CheckoutRefOptions{}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return self.c.Context().Push(self.c.Contexts().Branches)
|
self.c.Context().Push(self.c.Contexts().Branches)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *TagsController) localDelete(tag *models.Tag) error {
|
func (self *TagsController) localDelete(tag *models.Tag) error {
|
||||||
|
@ -17,9 +17,7 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error {
|
|||||||
OnPress: func() error {
|
OnPress: func() error {
|
||||||
currentContext := gui.c.Context().CurrentStatic()
|
currentContext := gui.c.Context().CurrentStatic()
|
||||||
if gui.c.State().GetShowExtrasWindow() && currentContext.GetKey() == context.COMMAND_LOG_CONTEXT_KEY {
|
if gui.c.State().GetShowExtrasWindow() && currentContext.GetKey() == context.COMMAND_LOG_CONTEXT_KEY {
|
||||||
if err := gui.c.Context().Pop(); err != nil {
|
gui.c.Context().Pop()
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
show := !gui.c.State().GetShowExtrasWindow()
|
show := !gui.c.State().GetShowExtrasWindow()
|
||||||
gui.c.State().SetShowExtrasWindow(show)
|
gui.c.State().SetShowExtrasWindow(show)
|
||||||
@ -40,7 +38,8 @@ func (gui *Gui) handleFocusCommandLog() error {
|
|||||||
gui.c.State().SetShowExtrasWindow(true)
|
gui.c.State().SetShowExtrasWindow(true)
|
||||||
// TODO: is this necessary? Can't I just call 'return from context'?
|
// TODO: is this necessary? Can't I just call 'return from context'?
|
||||||
gui.State.Contexts.CommandLog.SetParentContext(gui.c.Context().CurrentSide())
|
gui.State.Contexts.CommandLog.SetParentContext(gui.c.Context().CurrentSide())
|
||||||
return gui.c.Context().Push(gui.State.Contexts.CommandLog)
|
gui.c.Context().Push(gui.State.Contexts.CommandLog)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) scrollUpExtra() error {
|
func (gui *Gui) scrollUpExtra() error {
|
||||||
|
@ -393,9 +393,7 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.Context
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := gui.c.Context().Push(contextToPush); err != nil {
|
gui.c.Context().Push(contextToPush)
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -677,7 +675,7 @@ func NewGui(
|
|||||||
return gui.helpers.Confirmation.CreatePopupPanel(ctx, opts)
|
return gui.helpers.Confirmation.CreatePopupPanel(ctx, opts)
|
||||||
},
|
},
|
||||||
func() error { return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) },
|
func() error { return gui.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) },
|
||||||
func() error { return gui.State.ContextMgr.Pop() },
|
func() { gui.State.ContextMgr.Pop() },
|
||||||
func() types.Context { return gui.State.ContextMgr.Current() },
|
func() types.Context { return gui.State.ContextMgr.Current() },
|
||||||
gui.createMenu,
|
gui.createMenu,
|
||||||
func(message string, f func(gocui.Task) error) { gui.helpers.AppStatus.WithWaitingStatus(message, f) },
|
func(message string, f func(gocui.Task) error) { gui.helpers.AppStatus.WithWaitingStatus(message, f) },
|
||||||
|
@ -223,9 +223,7 @@ func (gui *Gui) onInitialViewsCreationForRepo() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
initialContext := gui.c.Context().Current()
|
initialContext := gui.c.Context().Current()
|
||||||
if err := gui.c.Context().Activate(initialContext, types.OnFocusOpts{}); err != nil {
|
gui.c.Context().Activate(initialContext, types.OnFocusOpts{})
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return gui.loadNewRepo()
|
return gui.loadNewRepo()
|
||||||
}
|
}
|
||||||
|
@ -60,5 +60,6 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error {
|
|||||||
_ = gui.c.PostRefreshUpdate(gui.State.Contexts.Menu)
|
_ = gui.c.PostRefreshUpdate(gui.State.Contexts.Menu)
|
||||||
|
|
||||||
// TODO: ensure that if we're opened a menu from within a menu that it renders correctly
|
// TODO: ensure that if we're opened a menu from within a menu that it renders correctly
|
||||||
return gui.c.Context().Push(gui.State.Contexts.Menu)
|
gui.c.Context().Push(gui.State.Contexts.Menu)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ type PopupHandler struct {
|
|||||||
*common.Common
|
*common.Common
|
||||||
createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) error
|
createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) error
|
||||||
onErrorFn func() error
|
onErrorFn func() error
|
||||||
popContextFn func() error
|
popContextFn func()
|
||||||
currentContextFn func() types.Context
|
currentContextFn func() types.Context
|
||||||
createMenuFn func(types.CreateMenuOptions) error
|
createMenuFn func(types.CreateMenuOptions) error
|
||||||
withWaitingStatusFn func(message string, f func(gocui.Task) error)
|
withWaitingStatusFn func(message string, f func(gocui.Task) error)
|
||||||
@ -30,7 +30,7 @@ func NewPopupHandler(
|
|||||||
common *common.Common,
|
common *common.Common,
|
||||||
createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) error,
|
createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) error,
|
||||||
onErrorFn func() error,
|
onErrorFn func() error,
|
||||||
popContextFn func() error,
|
popContextFn func(),
|
||||||
currentContextFn func() types.Context,
|
currentContextFn func() types.Context,
|
||||||
createMenuFn func(types.CreateMenuOptions) error,
|
createMenuFn func(types.CreateMenuOptions) error,
|
||||||
withWaitingStatusFn func(message string, f func(gocui.Task) error),
|
withWaitingStatusFn func(message string, f func(gocui.Task) error),
|
||||||
|
@ -278,10 +278,10 @@ type ListItem interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IContextMgr interface {
|
type IContextMgr interface {
|
||||||
Push(context Context, opts ...OnFocusOpts) error
|
Push(context Context, opts ...OnFocusOpts)
|
||||||
Pop() error
|
Pop()
|
||||||
Replace(context Context) error
|
Replace(context Context)
|
||||||
Activate(context Context, opts OnFocusOpts) error
|
Activate(context Context, opts OnFocusOpts)
|
||||||
Current() Context
|
Current() Context
|
||||||
CurrentStatic() Context
|
CurrentStatic() Context
|
||||||
CurrentSide() Context
|
CurrentSide() Context
|
||||||
|
@ -72,7 +72,8 @@ func (gui *Gui) onViewTabClick(windowName string, tabIndex int) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
return gui.c.Context().Push(context)
|
gui.c.Context().Push(context)
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handleNextTab() error {
|
func (gui *Gui) handleNextTab() error {
|
||||||
|
Reference in New Issue
Block a user