diff --git a/go.mod b/go.mod index 36350778cde..6836caeb9c9 100644 --- a/go.mod +++ b/go.mod @@ -16,7 +16,7 @@ require ( github.com/integrii/flaggy v1.4.0 github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d - github.com/jesseduffield/gocui v0.3.1-0.20240824154427-0fc91d5098e4 + github.com/jesseduffield/gocui v0.3.1-0.20240906064314-bfab49c720d7 github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e @@ -75,8 +75,8 @@ require ( github.com/xanzy/ssh-agent v0.2.1 // indirect golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/term v0.23.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/sys v0.25.0 // indirect + golang.org/x/term v0.24.0 // indirect + golang.org/x/text v0.18.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect ) diff --git a/go.sum b/go.sum index 9793cd69ba9..77fc93c8b88 100644 --- a/go.sum +++ b/go.sum @@ -188,8 +188,8 @@ github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68 h1:EQP2Tv8T github.com/jesseduffield/generics v0.0.0-20220320043834-727e535cbe68/go.mod h1:+LLj9/WUPAP8LqCchs7P+7X0R98HiFujVFANdNaxhGk= github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d h1:bO+OmbreIv91rCe8NmscRwhFSqkDJtzWCPV4Y+SQuXE= github.com/jesseduffield/go-git/v5 v5.1.2-0.20221018185014-fdd53fef665d/go.mod h1:nGNEErzf+NRznT+N2SWqmHnDnF9aLgANB1CUNEan09o= -github.com/jesseduffield/gocui v0.3.1-0.20240824154427-0fc91d5098e4 h1:2su9wjacqT/WxvNrzzdvA6rBJa6n/yZ/jvaS1r60HfM= -github.com/jesseduffield/gocui v0.3.1-0.20240824154427-0fc91d5098e4/go.mod h1:XtEbqCbn45keRXEu+OMZkjN5gw6AEob59afsgHjokZ8= +github.com/jesseduffield/gocui v0.3.1-0.20240906064314-bfab49c720d7 h1:QeLCKRAt4T6sBg5tSrOc4OojCuAcPxUA+4vNMPY4aH4= +github.com/jesseduffield/gocui v0.3.1-0.20240906064314-bfab49c720d7/go.mod h1:XtEbqCbn45keRXEu+OMZkjN5gw6AEob59afsgHjokZ8= github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 h1:jmpr7KpX2+2GRiE91zTgfq49QvgiqB0nbmlwZ8UnOx0= github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10/go.mod h1:aA97kHeNA+sj2Hbki0pvLslmE4CbDyhBeSSTUUnOuVo= github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 h1:CDuQmfOjAtb1Gms6a1p5L2P8RhbLUq5t8aL7PiQd2uY= @@ -475,14 +475,14 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= -golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= +golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -493,8 +493,8 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= +golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/pkg/gui/background.go b/pkg/gui/background.go index 7c81def3916..0272f0864ef 100644 --- a/pkg/gui/background.go +++ b/pkg/gui/background.go @@ -83,7 +83,7 @@ func (self *BackgroundRoutineMgr) startBackgroundFetch() { } err := self.backgroundFetch() if err != nil && strings.Contains(err.Error(), "exit status 128") && isNew { - _ = self.gui.c.Alert(self.gui.c.Tr.NoAutomaticGitFetchTitle, self.gui.c.Tr.NoAutomaticGitFetchBody) + self.gui.c.Alert(self.gui.c.Tr.NoAutomaticGitFetchTitle, self.gui.c.Tr.NoAutomaticGitFetchBody) } else { self.goEvery(time.Second*time.Duration(userConfig.Refresher.FetchInterval), self.gui.stopChan, func() error { err := self.backgroundFetch() diff --git a/pkg/gui/context.go b/pkg/gui/context.go index 3ac1425fbdb..36f4e9ddaba 100644 --- a/pkg/gui/context.go +++ b/pkg/gui/context.go @@ -1,7 +1,6 @@ package gui import ( - "errors" "sync" "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 // 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() { - return nil + return } self.Lock() @@ -51,14 +50,14 @@ func (self *ContextMgr) Replace(c types.Context) error { self.ContextStack = append(self.ContextStack[0:len(self.ContextStack)-1], c) } - defer 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 { - return errors.New("cannot pass multiple opts to Push") + panic("cannot pass multiple opts to Push") } singleOpts := types.OnFocusOpts{} @@ -68,22 +67,18 @@ func (self *ContextMgr) Push(c types.Context, opts ...types.OnFocusOpts) error { } if !c.IsFocusable() { - return nil + return } contextsToDeactivate, contextToActivate := self.pushToContextStack(c) for _, contextToDeactivate := range contextsToDeactivate { - if err := self.deactivate(contextToDeactivate, types.OnFocusLostOpts{NewContextKey: c.GetKey()}); err != nil { - return err - } + self.deactivate(contextToDeactivate, types.OnFocusLostOpts{NewContextKey: c.GetKey()}) } - if contextToActivate == nil { - return nil + if contextToActivate != nil { + self.Activate(contextToActivate, singleOpts) } - - return self.Activate(contextToActivate, singleOpts) } // 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 } -func (self *ContextMgr) Pop() error { +func (self *ContextMgr) Pop() { self.Lock() if len(self.ContextStack) == 1 { // cannot escape from bottommost context self.Unlock() - return nil + return } var currentContext types.Context @@ -160,14 +155,12 @@ func (self *ContextMgr) Pop() error { self.Unlock() - if err := self.deactivate(currentContext, types.OnFocusLostOpts{NewContextKey: newContext.GetKey()}); err != nil { - return err - } + self.deactivate(currentContext, types.OnFocusLostOpts{NewContextKey: newContext.GetKey()}) - return self.Activate(newContext, types.OnFocusOpts{}) + self.Activate(newContext, types.OnFocusOpts{}) } -func (self *ContextMgr) deactivate(c types.Context, opts types.OnFocusLostOpts) error { +func (self *ContextMgr) deactivate(c types.Context, opts types.OnFocusLostOpts) { view, _ := self.gui.c.GocuiGui().View(c.GetViewName()) if opts.NewContextKey != context.SEARCH_CONTEXT_KEY { @@ -183,18 +176,14 @@ func (self *ContextMgr) deactivate(c types.Context, opts types.OnFocusLostOpts) view.Visible = false } - if err := c.HandleFocusLost(opts); err != nil { - return err - } - - return nil + c.HandleFocusLost(opts) } -func (self *ContextMgr) Activate(c types.Context, opts types.OnFocusOpts) error { +func (self *ContextMgr) Activate(c types.Context, opts types.OnFocusOpts) { viewName := c.GetViewName() v, err := self.gui.c.GocuiGui().View(viewName) if err != nil { - return err + panic(err) } self.gui.helpers.Window.SetWindowContext(c) @@ -205,7 +194,7 @@ func (self *ContextMgr) Activate(c types.Context, opts types.OnFocusOpts) error oldView.HighlightInactive = true } if _, err := self.gui.c.GocuiGui().SetCurrentView(viewName); err != nil { - return err + panic(err) } self.gui.helpers.Search.RenderSearchStatus(c) @@ -219,11 +208,7 @@ func (self *ContextMgr) Activate(c types.Context, opts types.OnFocusOpts) error self.gui.c.GocuiGui().Cursor = v.Editable - if err := c.HandleFocus(opts); err != nil { - return err - } - - return nil + c.HandleFocus(opts) } func (self *ContextMgr) Current() types.Context { diff --git a/pkg/gui/context/base_context.go b/pkg/gui/context/base_context.go index 2fd37bb9a85..76482ad0f35 100644 --- a/pkg/gui/context/base_context.go +++ b/pkg/gui/context/base_context.go @@ -16,7 +16,7 @@ type BaseContext struct { keybindingsFns []types.KeybindingsFn mouseKeybindingsFns []types.MouseKeybindingsFn onClickFn func() error - onRenderToMainFn func() error + onRenderToMainFn func() onFocusFn onFocusFn onFocusLostFn onFocusLostFn @@ -31,8 +31,8 @@ type BaseContext struct { } type ( - onFocusFn = func(types.OnFocusOpts) error - onFocusLostFn = func(types.OnFocusLostOpts) error + onFocusFn = func(types.OnFocusOpts) + onFocusLostFn = func(types.OnFocusLostOpts) ) var _ types.IBaseContext = &BaseContext{} @@ -148,13 +148,13 @@ func (self *BaseContext) GetOnClick() func() error { return self.onClickFn } -func (self *BaseContext) AddOnRenderToMainFn(fn func() error) { +func (self *BaseContext) AddOnRenderToMainFn(fn func()) { if fn != nil { self.onRenderToMainFn = fn } } -func (self *BaseContext) GetOnRenderToMain() func() error { +func (self *BaseContext) GetOnRenderToMain() func() { return self.onRenderToMainFn } diff --git a/pkg/gui/context/list_context_trait.go b/pkg/gui/context/list_context_trait.go index bce3ae34420..874e4648ff5 100644 --- a/pkg/gui/context/list_context_trait.go +++ b/pkg/gui/context/list_context_trait.go @@ -49,7 +49,7 @@ func (self *ListContextTrait) FocusLine() { } else if self.renderOnlyVisibleLines { newOrigin, _ := self.GetViewTrait().ViewPortYBounds() if oldOrigin != newOrigin { - return self.HandleRender() + self.HandleRender() } } return nil @@ -72,26 +72,26 @@ func formatListFooter(selectedLineIdx int, length int) string { return fmt.Sprintf("%d of %d", selectedLineIdx+1, length) } -func (self *ListContextTrait) HandleFocus(opts types.OnFocusOpts) error { +func (self *ListContextTrait) HandleFocus(opts types.OnFocusOpts) { self.FocusLine() self.GetViewTrait().SetHighlight(self.list.Len() > 0) - return self.Context.HandleFocus(opts) + self.Context.HandleFocus(opts) } -func (self *ListContextTrait) HandleFocusLost(opts types.OnFocusLostOpts) error { +func (self *ListContextTrait) HandleFocusLost(opts types.OnFocusLostOpts) { self.GetViewTrait().SetOriginX(0) if self.refreshViewportOnChange { self.refreshViewport() } - return self.Context.HandleFocusLost(opts) + self.Context.HandleFocusLost(opts) } // OnFocus assumes that the content of the context has already been rendered to the view. OnRender is the function which actually renders the content to the view -func (self *ListContextTrait) HandleRender() error { +func (self *ListContextTrait) HandleRender() { self.list.ClampSelection() if self.renderOnlyVisibleLines { // Rendering only the visible area can save a lot of cell memory for @@ -110,13 +110,12 @@ func (self *ListContextTrait) HandleRender() error { } self.c.Render() self.setFooter() - - return nil } func (self *ListContextTrait) OnSearchSelect(selectedLineIdx int) error { self.GetList().SetSelection(self.ViewIndexToModelIndex(selectedLineIdx)) - return self.HandleFocus(types.OnFocusOpts{}) + self.HandleFocus(types.OnFocusOpts{}) + return nil } func (self *ListContextTrait) IsItemVisible(item types.HasUrn) bool { diff --git a/pkg/gui/context/menu_context.go b/pkg/gui/context/menu_context.go index ec738681cfe..26425af3d18 100644 --- a/pkg/gui/context/menu_context.go +++ b/pkg/gui/context/menu_context.go @@ -197,9 +197,7 @@ func (self *MenuContext) OnMenuPress(selectedItem *types.MenuItem) error { return nil } - if err := self.c.Context().Pop(); err != nil { - return err - } + self.c.Context().Pop() if selectedItem == nil { return nil diff --git a/pkg/gui/context/merge_conflicts_context.go b/pkg/gui/context/merge_conflicts_context.go index 1cfe3c50ad2..b265fa88e54 100644 --- a/pkg/gui/context/merge_conflicts_context.go +++ b/pkg/gui/context/merge_conflicts_context.go @@ -68,13 +68,11 @@ func (self *MergeConflictsContext) IsUserScrolling() bool { return self.viewModel.userVerticalScrolling } -func (self *MergeConflictsContext) RenderAndFocus() error { +func (self *MergeConflictsContext) RenderAndFocus() { self.setContent() self.FocusSelection() self.c.Render() - - return nil } func (self *MergeConflictsContext) Render() error { @@ -99,7 +97,7 @@ func (self *MergeConflictsContext) setContent() { func (self *MergeConflictsContext) FocusSelection() { if !self.IsUserScrolling() { - _ = self.GetView().SetOriginY(self.GetOriginY()) + self.GetView().SetOriginY(self.GetOriginY()) } self.SetSelectedLineRange() diff --git a/pkg/gui/context/patch_explorer_context.go b/pkg/gui/context/patch_explorer_context.go index ac88901918e..330f0a55760 100644 --- a/pkg/gui/context/patch_explorer_context.go +++ b/pkg/gui/context/patch_explorer_context.go @@ -53,7 +53,8 @@ func NewPatchExplorerContext( func(selectedLineIdx int) error { ctx.GetMutex().Lock() defer ctx.GetMutex().Unlock() - return ctx.NavigateTo(ctx.c.Context().IsCurrent(ctx), selectedLineIdx) + ctx.NavigateTo(ctx.c.Context().IsCurrent(ctx), selectedLineIdx) + return nil }), ) @@ -78,28 +79,22 @@ func (self *PatchExplorerContext) GetIncludedLineIndices() []int { return self.getIncludedLineIndices() } -func (self *PatchExplorerContext) RenderAndFocus(isFocused bool) error { +func (self *PatchExplorerContext) RenderAndFocus(isFocused bool) { self.setContent(isFocused) self.FocusSelection() self.c.Render() - - return nil } -func (self *PatchExplorerContext) Render(isFocused bool) error { +func (self *PatchExplorerContext) Render(isFocused bool) { self.setContent(isFocused) self.c.Render() - - return nil } -func (self *PatchExplorerContext) Focus() error { +func (self *PatchExplorerContext) Focus() { self.FocusSelection() self.c.Render() - - return nil } func (self *PatchExplorerContext) setContent(isFocused bool) { @@ -116,7 +111,7 @@ func (self *PatchExplorerContext) FocusSelection() { newOriginY := state.CalculateOrigin(origin, bufferHeight, numLines) - _ = view.SetOriginY(newOriginY) + view.SetOriginY(newOriginY) startIdx, endIdx := state.SelectedRange() // As far as the view is concerned, we are always selecting a range @@ -132,11 +127,11 @@ func (self *PatchExplorerContext) GetContentToRender(isFocused bool) string { return self.GetState().RenderForLineIndices(isFocused, self.GetIncludedLineIndices()) } -func (self *PatchExplorerContext) NavigateTo(isFocused bool, selectedLineIdx int) error { +func (self *PatchExplorerContext) NavigateTo(isFocused bool, selectedLineIdx int) { self.GetState().SetLineSelectMode() self.GetState().SelectLine(selectedLineIdx) - return self.RenderAndFocus(isFocused) + self.RenderAndFocus(isFocused) } func (self *PatchExplorerContext) GetMutex() *deadlock.Mutex { diff --git a/pkg/gui/context/simple_context.go b/pkg/gui/context/simple_context.go index cef871cefea..d78db719075 100644 --- a/pkg/gui/context/simple_context.go +++ b/pkg/gui/context/simple_context.go @@ -31,43 +31,33 @@ func NewDisplayContext(key types.ContextKey, view *gocui.View, windowName string ) } -func (self *SimpleContext) HandleFocus(opts types.OnFocusOpts) error { +func (self *SimpleContext) HandleFocus(opts types.OnFocusOpts) { if self.highlightOnFocus { self.GetViewTrait().SetHighlight(true) } if self.onFocusFn != nil { - if err := self.onFocusFn(opts); err != nil { - return err - } + self.onFocusFn(opts) } if self.onRenderToMainFn != nil { - if err := self.onRenderToMainFn(); err != nil { - return err - } + self.onRenderToMainFn() } - - return nil } -func (self *SimpleContext) HandleFocusLost(opts types.OnFocusLostOpts) error { +func (self *SimpleContext) HandleFocusLost(opts types.OnFocusLostOpts) { self.GetViewTrait().SetHighlight(false) - _ = self.view.SetOriginX(0) + self.view.SetOriginX(0) if self.onFocusLostFn != nil { - return self.onFocusLostFn(opts) + self.onFocusLostFn(opts) } - return nil } -func (self *SimpleContext) HandleRender() error { - return nil +func (self *SimpleContext) HandleRender() { } -func (self *SimpleContext) HandleRenderToMain() error { +func (self *SimpleContext) HandleRenderToMain() { if self.onRenderToMainFn != nil { - return self.onRenderToMainFn() + self.onRenderToMainFn() } - - return nil } diff --git a/pkg/gui/context/suggestions_context.go b/pkg/gui/context/suggestions_context.go index c741cc769a9..9e3b8ba95a2 100644 --- a/pkg/gui/context/suggestions_context.go +++ b/pkg/gui/context/suggestions_context.go @@ -70,7 +70,7 @@ func (self *SuggestionsContext) SetSuggestions(suggestions []*types.Suggestion) self.State.Suggestions = suggestions self.SetSelection(0) self.c.ResetViewOrigin(self.GetView()) - _ = self.HandleRender() + self.HandleRender() } func (self *SuggestionsContext) RefreshSuggestions() { diff --git a/pkg/gui/context/view_trait.go b/pkg/gui/context/view_trait.go index 5342071ef88..ee1a6d7e8ea 100644 --- a/pkg/gui/context/view_trait.go +++ b/pkg/gui/context/view_trait.go @@ -57,7 +57,7 @@ func (self *ViewTrait) SetFooter(value string) { } func (self *ViewTrait) SetOriginX(value int) { - _ = self.view.SetOriginX(value) + self.view.SetOriginX(value) } // tells us the start of line indexes shown in the view currently as well as the capacity of lines shown in the viewport. diff --git a/pkg/gui/controllers/base_controller.go b/pkg/gui/controllers/base_controller.go index 100acfd2a32..adff1927aa2 100644 --- a/pkg/gui/controllers/base_controller.go +++ b/pkg/gui/controllers/base_controller.go @@ -19,14 +19,14 @@ func (self *baseController) GetOnClick() func() error { return nil } -func (self *baseController) GetOnRenderToMain() func() error { +func (self *baseController) GetOnRenderToMain() func() { return nil } -func (self *baseController) GetOnFocus() func(types.OnFocusOpts) error { +func (self *baseController) GetOnFocus() func(types.OnFocusOpts) { return nil } -func (self *baseController) GetOnFocusLost() func(types.OnFocusLostOpts) error { +func (self *baseController) GetOnFocusLost() func(types.OnFocusLostOpts) { return nil } diff --git a/pkg/gui/controllers/basic_commits_controller.go b/pkg/gui/controllers/basic_commits_controller.go index 9d3595a6189..ac0ffb39414 100644 --- a/pkg/gui/controllers/basic_commits_controller.go +++ b/pkg/gui/controllers/basic_commits_controller.go @@ -280,7 +280,7 @@ func (self *BasicCommitsController) createResetMenu(commit *models.Commit) error } func (self *BasicCommitsController) checkout(commit *models.Commit) error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.CheckoutCommit, Prompt: self.c.Tr.SureCheckoutThisCommit, HandleConfirm: func() error { @@ -288,6 +288,7 @@ func (self *BasicCommitsController) checkout(commit *models.Commit) error { return self.c.Helpers().Refs.CheckoutRef(commit.Hash, types.CheckoutRefOptions{}) }, }) + return nil } func (self *BasicCommitsController) copyRange(*models.Commit) error { diff --git a/pkg/gui/controllers/bisect_controller.go b/pkg/gui/controllers/bisect_controller.go index 0db5701077f..ee4b6aecff4 100644 --- a/pkg/gui/controllers/bisect_controller.go +++ b/pkg/gui/controllers/bisect_controller.go @@ -201,10 +201,10 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, { Label: self.c.Tr.Bisect.ChooseTerms, OnPress: func() error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.Bisect.OldTermPrompt, HandleConfirm: func(oldTerm string) error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.Bisect.NewTermPrompt, HandleConfirm: func(newTerm string) error { self.c.LogAction(self.c.Tr.Actions.StartBisect) @@ -215,8 +215,10 @@ func (self *BisectController) openStartBisectMenu(info *git_commands.BisectInfo, return self.c.Helpers().Bisect.PostBisectCommandRefresh() }, }) + return nil }, }) + return nil }, Key: 't', }, @@ -235,7 +237,7 @@ func (self *BisectController) showBisectCompleteMessage(candidateHashes []string return err } - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Bisect.CompleteTitle, Prompt: fmt.Sprintf(prompt, strings.TrimSpace(formattedCommits)), HandleConfirm: func() error { @@ -247,6 +249,8 @@ func (self *BisectController) showBisectCompleteMessage(candidateHashes []string return self.c.Helpers().Bisect.PostBisectCommandRefresh() }, }) + + return nil } func (self *BisectController) afterMark(selectCurrent bool, waitToReselect bool) error { @@ -290,7 +294,7 @@ func (self *BisectController) selectCurrentBisectCommit() { for i, commit := range self.c.Model().Commits { if commit.Hash == info.GetCurrentHash() { self.context().SetSelection(i) - _ = self.context().HandleFocus(types.OnFocusOpts{}) + self.context().HandleFocus(types.OnFocusOpts{}) break } } diff --git a/pkg/gui/controllers/branches_controller.go b/pkg/gui/controllers/branches_controller.go index d22e56f1c9c..5a7561f326b 100644 --- a/pkg/gui/controllers/branches_controller.go +++ b/pkg/gui/controllers/branches_controller.go @@ -170,9 +170,9 @@ func (self *BranchesController) GetKeybindings(opts types.KeybindingsOpts) []*ty } } -func (self *BranchesController) GetOnRenderToMain() func() error { - return func() error { - return self.c.Helpers().Diff.WithDiffModeCheck(func() error { +func (self *BranchesController) GetOnRenderToMain() func() { + return func() { + self.c.Helpers().Diff.WithDiffModeCheck(func() { var task types.UpdateTask branch := self.context().GetSelected() if branch == nil { @@ -183,7 +183,7 @@ func (self *BranchesController) GetOnRenderToMain() func() error { task = types.NewRunPtyTask(cmdObj.GetCmd()) } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: self.c.Tr.LogTitle, @@ -410,13 +410,15 @@ func (self *BranchesController) promptToCheckoutWorktree(worktree *models.Worktr "worktreeName": worktree.Name, }) - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.SwitchToWorktree, Prompt: prompt, HandleConfirm: func() error { return self.c.Helpers().Worktree.Switch(worktree, context.LOCAL_BRANCHES_CONTEXT_KEY) }, }) + + return nil } func (self *BranchesController) handleCreatePullRequest(selectedBranch *models.Branch) error { @@ -460,7 +462,7 @@ func (self *BranchesController) forceCheckout() error { message := self.c.Tr.SureForceCheckout title := self.c.Tr.ForceCheckoutBranch - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: title, Prompt: message, HandleConfirm: func() error { @@ -471,10 +473,12 @@ func (self *BranchesController) forceCheckout() error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) }, }) + + return nil } func (self *BranchesController) checkoutByName() error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.BranchName + ":", FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRefsSuggestionsFunc(), HandleConfirm: func(response string) error { @@ -485,18 +489,22 @@ func (self *BranchesController) checkoutByName() error { } return self.c.Helpers().Refs.CheckoutRef(response, types.CheckoutRefOptions{ OnRefNotFound: func(ref string) error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.BranchNotFoundTitle, Prompt: fmt.Sprintf("%s %s%s", self.c.Tr.BranchNotFoundPrompt, ref, "?"), HandleConfirm: func() error { return self.createNewBranchWithName(ref) }, }) + + return nil }, }) }, }, ) + + return nil } func (self *BranchesController) createNewBranchWithName(newBranchName string) error { @@ -586,7 +594,7 @@ func (self *BranchesController) forceDelete(branch *models.Branch) error { }, ) - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: title, Prompt: message, HandleConfirm: func() error { @@ -596,6 +604,8 @@ func (self *BranchesController) forceDelete(branch *models.Branch) error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.BRANCHES}}) }, }) + + return nil } func (self *BranchesController) delete(branch *models.Branch) error { @@ -715,7 +725,7 @@ func (self *BranchesController) createResetMenu(selectedBranch *models.Branch) e func (self *BranchesController) rename(branch *models.Branch) error { promptForNewName := func() error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.NewBranchNamePrompt + " " + branch.Name + ":", InitialContent: branch.Name, HandleConfirm: func(newBranchName string) error { @@ -734,15 +744,15 @@ func (self *BranchesController) rename(branch *models.Branch) error { for i, newBranch := range self.c.Model().Branches { if newBranch.Name == newBranchName { self.context().SetSelection(i) - if err := self.context().HandleRender(); err != nil { - return err - } + self.context().HandleRender() } } return nil }, }) + + return nil } // I could do an explicit check here for whether the branch is tracking a remote branch @@ -752,11 +762,13 @@ func (self *BranchesController) rename(branch *models.Branch) error { return promptForNewName() } - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.RenameBranch, Prompt: self.c.Tr.RenameBranchWarning, HandleConfirm: promptForNewName, }) + + return nil } func (self *BranchesController) newBranch(selectedBranch *models.Branch) error { @@ -781,13 +793,15 @@ func (self *BranchesController) createPullRequestMenu(selectedBranch *models.Bra { LabelColumns: fromToLabelColumns(branch.Name, self.c.Tr.SelectBranch), OnPress: func() error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: branch.Name + " →", FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRemoteBranchesSuggestionsFunc("/"), HandleConfirm: func(targetBranchName string) error { return self.createPullRequest(branch.Name, targetBranchName) }, }) + + return nil }, }, } diff --git a/pkg/gui/controllers/command_log_controller.go b/pkg/gui/controllers/command_log_controller.go index 92b6540be61..3056a9d96c2 100644 --- a/pkg/gui/controllers/command_log_controller.go +++ b/pkg/gui/controllers/command_log_controller.go @@ -26,10 +26,9 @@ func (self *CommandLogController) GetKeybindings(opts types.KeybindingsOpts) []* return bindings } -func (self *CommandLogController) GetOnFocusLost() func(types.OnFocusLostOpts) error { - return func(types.OnFocusLostOpts) error { +func (self *CommandLogController) GetOnFocusLost() func(types.OnFocusLostOpts) { + return func(types.OnFocusLostOpts) { self.c.Views().Extras.Autoscroll = true - return nil } } diff --git a/pkg/gui/controllers/commit_description_controller.go b/pkg/gui/controllers/commit_description_controller.go index 447a83f5afc..9f1fe78e58d 100644 --- a/pkg/gui/controllers/commit_description_controller.go +++ b/pkg/gui/controllers/commit_description_controller.go @@ -60,11 +60,13 @@ func (self *CommitDescriptionController) GetMouseKeybindings(opts types.Keybindi } 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 { - return self.c.Helpers().Commits.CloseCommitMessagePanel() + self.c.Helpers().Commits.CloseCommitMessagePanel() + return nil } func (self *CommitDescriptionController) confirm() error { @@ -79,7 +81,7 @@ func (self *CommitDescriptionController) openCommitMenu() error { func (self *CommitDescriptionController) onClick(opts gocui.ViewMouseBindingOpts) error { // Activate the description panel when the commit message panel is currently active 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 diff --git a/pkg/gui/controllers/commit_message_controller.go b/pkg/gui/controllers/commit_message_controller.go index 1b2c3aef875..93be127a00b 100644 --- a/pkg/gui/controllers/commit_message_controller.go +++ b/pkg/gui/controllers/commit_message_controller.go @@ -69,10 +69,9 @@ func (self *CommitMessageController) GetMouseKeybindings(opts types.KeybindingsO } } -func (self *CommitMessageController) GetOnFocusLost() func(types.OnFocusLostOpts) error { - return func(types.OnFocusLostOpts) error { +func (self *CommitMessageController) GetOnFocusLost() func(types.OnFocusLostOpts) { + return func(types.OnFocusLostOpts) { self.context().RenderCommitLength() - return nil } } @@ -96,9 +95,7 @@ func (self *CommitMessageController) handleNextCommit() error { } func (self *CommitMessageController) switchToCommitDescription() error { - if err := self.c.Context().Replace(self.c.Contexts().CommitDescription); err != nil { - return err - } + self.c.Context().Replace(self.c.Contexts().CommitDescription) return nil } @@ -141,7 +138,8 @@ func (self *CommitMessageController) confirm() error { } func (self *CommitMessageController) close() error { - return self.c.Helpers().Commits.CloseCommitMessagePanel() + self.c.Helpers().Commits.CloseCommitMessagePanel() + return nil } func (self *CommitMessageController) openCommitMenu() error { @@ -152,7 +150,7 @@ func (self *CommitMessageController) openCommitMenu() error { func (self *CommitMessageController) onClick(opts gocui.ViewMouseBindingOpts) error { // Activate the commit message panel when the commit description panel is currently active 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 diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index 8c4f7cf14b2..a675307312e 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -129,11 +129,11 @@ func (self *CommitFilesController) context() *context.CommitFilesContext { return self.c.Contexts().CommitFiles } -func (self *CommitFilesController) GetOnRenderToMain() func() error { - return func() error { +func (self *CommitFilesController) GetOnRenderToMain() func() { + return func() { node := self.context().GetSelected() if node == nil { - return nil + return } from, to := self.context().GetFromAndToForDiff() @@ -147,7 +147,7 @@ func (self *CommitFilesController) GetOnRenderToMain() func() error { pair = self.c.MainViewPairs().PatchBuilding } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: pair, Main: &types.ViewUpdateOpts{ Title: self.c.Tr.Patch, @@ -186,7 +186,7 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN return err } - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardFileChangesTitle, Prompt: self.c.Tr.DiscardFileChangesPrompt, HandleConfirm: func() error { @@ -224,6 +224,8 @@ func (self *CommitFilesController) discard(selectedNodes []*filetree.CommitFileN }) }, }) + + return nil } func (self *CommitFilesController) open(node *filetree.CommitFileNode) error { @@ -307,7 +309,7 @@ func (self *CommitFilesController) toggleForPatch(selectedNodes []*filetree.Comm from, to, reverse := self.currentFromToReverseForPatchBuilding() if self.c.Git().Patch.PatchBuilder.Active() && self.c.Git().Patch.PatchBuilder.NewPatchRequired(from, to, reverse) { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardPatch, Prompt: self.c.Tr.DiscardPatchConfirm, HandleConfirm: func() error { @@ -315,6 +317,8 @@ func (self *CommitFilesController) toggleForPatch(selectedNodes []*filetree.Comm return toggle() }, }) + + return nil } return toggle() @@ -359,12 +363,13 @@ 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() if self.c.Git().Patch.PatchBuilder.Active() && self.c.Git().Patch.PatchBuilder.NewPatchRequired(from, to, reverse) { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardPatch, Prompt: self.c.Tr.DiscardPatchConfirm, HandleConfirm: func() error { @@ -372,6 +377,8 @@ func (self *CommitFilesController) enterCommitFile(node *filetree.CommitFileNode return enterTheFile() }, }) + + return nil } return enterTheFile() diff --git a/pkg/gui/controllers/confirmation_controller.go b/pkg/gui/controllers/confirmation_controller.go index 042f8311508..6bfff6b98f6 100644 --- a/pkg/gui/controllers/confirmation_controller.go +++ b/pkg/gui/controllers/confirmation_controller.go @@ -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.Views().Suggestions.Subtitle = subtitle - return self.c.Context().Replace(self.c.Contexts().Suggestions) + self.c.Context().Replace(self.c.Contexts().Suggestions) } return nil }, @@ -59,10 +59,9 @@ func (self *ConfirmationController) GetKeybindings(opts types.KeybindingsOpts) [ return bindings } -func (self *ConfirmationController) GetOnFocusLost() func(types.OnFocusLostOpts) error { - return func(types.OnFocusLostOpts) error { +func (self *ConfirmationController) GetOnFocusLost() func(types.OnFocusLostOpts) { + return func(types.OnFocusLostOpts) { self.c.Helpers().Confirmation.DeactivateConfirmationPrompt() - return nil } } diff --git a/pkg/gui/controllers/context_lines_controller.go b/pkg/gui/controllers/context_lines_controller.go index bdebd09496f..cd9cf7481a3 100644 --- a/pkg/gui/controllers/context_lines_controller.go +++ b/pkg/gui/controllers/context_lines_controller.go @@ -102,7 +102,8 @@ func (self *ContextLinesController) applyChange() error { case context.STAGING_MAIN_CONTEXT_KEY, context.STAGING_SECONDARY_CONTEXT_KEY: return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STAGING}}) default: - return currentContext.HandleRenderToMain() + currentContext.HandleRenderToMain() + return nil } } diff --git a/pkg/gui/controllers/custom_patch_options_menu_action.go b/pkg/gui/controllers/custom_patch_options_menu_action.go index 5c9cbd2c5ed..04895ed6b42 100644 --- a/pkg/gui/controllers/custom_patch_options_menu_action.go +++ b/pkg/gui/controllers/custom_patch_options_menu_action.go @@ -121,11 +121,10 @@ func (self *CustomPatchOptionsMenuAction) validateNormalWorkingTreeState() (bool return true, nil } -func (self *CustomPatchOptionsMenuAction) returnFocusFromPatchExplorerIfNecessary() error { +func (self *CustomPatchOptionsMenuAction) returnFocusFromPatchExplorerIfNecessary() { 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 { @@ -133,9 +132,7 @@ func (self *CustomPatchOptionsMenuAction) handleDeletePatchFromCommit() error { return err } - if err := self.returnFocusFromPatchExplorerIfNecessary(); err != nil { - return err - } + self.returnFocusFromPatchExplorerIfNecessary() return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error { commitIndex := self.getPatchCommitIndex() @@ -150,9 +147,7 @@ func (self *CustomPatchOptionsMenuAction) handleMovePatchToSelectedCommit() erro return err } - if err := self.returnFocusFromPatchExplorerIfNecessary(); err != nil { - return err - } + self.returnFocusFromPatchExplorerIfNecessary() return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error { commitIndex := self.getPatchCommitIndex() @@ -167,9 +162,7 @@ func (self *CustomPatchOptionsMenuAction) handleMovePatchIntoWorkingTree() error return err } - if err := self.returnFocusFromPatchExplorerIfNecessary(); err != nil { - return err - } + self.returnFocusFromPatchExplorerIfNecessary() pull := func(stash bool) error { return self.c.WithWaitingStatus(self.c.Tr.RebasingStatus, func(gocui.Task) error { @@ -181,13 +174,15 @@ func (self *CustomPatchOptionsMenuAction) handleMovePatchIntoWorkingTree() error } if self.c.Helpers().WorkingTree.IsWorkingTreeDirty() { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.MustStashTitle, Prompt: self.c.Tr.MustStashWarning, HandleConfirm: func() error { return pull(true) }, }) + + return nil } else { return pull(false) } @@ -198,12 +193,10 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error { return err } - if err := self.returnFocusFromPatchExplorerIfNecessary(); err != nil { - return err - } + self.returnFocusFromPatchExplorerIfNecessary() commitIndex := self.getPatchCommitIndex() - return self.c.Helpers().Commits.OpenCommitMessagePanel( + self.c.Helpers().Commits.OpenCommitMessagePanel( &helpers.OpenCommitMessagePanelOpts{ // Pass a commit index of one less than the moved-from commit, so that // you can press up arrow once to recall the original commit message: @@ -214,23 +207,24 @@ func (self *CustomPatchOptionsMenuAction) handlePullPatchIntoNewCommit() error { PreserveMessage: false, OnConfirm: func(summary string, description string) 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) err := self.c.Git().Patch.PullPatchIntoNewCommit(self.c.Model().Commits, commitIndex, summary, description) if err := self.c.Helpers().MergeAndRebase.CheckMergeOrRebase(err); err != nil { return err } - return self.c.Context().Push(self.c.Contexts().LocalCommits) + self.c.Context().Push(self.c.Contexts().LocalCommits) + return nil }) }, }, ) + + return nil } func (self *CustomPatchOptionsMenuAction) handleApplyPatch(reverse bool) error { - if err := self.returnFocusFromPatchExplorerIfNecessary(); err != nil { - return err - } + self.returnFocusFromPatchExplorerIfNecessary() action := self.c.Tr.Actions.ApplyPatch if reverse { diff --git a/pkg/gui/controllers/diffing_menu_action.go b/pkg/gui/controllers/diffing_menu_action.go index be44e471bea..3ff3846ab7c 100644 --- a/pkg/gui/controllers/diffing_menu_action.go +++ b/pkg/gui/controllers/diffing_menu_action.go @@ -33,7 +33,7 @@ func (self *DiffingMenuAction) Call() error { { Label: self.c.Tr.EnterRefToDiff, OnPress: func() error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.EnterRefName, FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRefsSuggestionsFunc(), HandleConfirm: func(response string) error { @@ -41,6 +41,8 @@ func (self *DiffingMenuAction) Call() error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) }, }) + + return nil }, }, }...) diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 25093a1c7e2..4169c911652 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -224,13 +224,13 @@ func (self *FilesController) GetMouseKeybindings(opts types.KeybindingsOpts) []* } } -func (self *FilesController) GetOnRenderToMain() func() error { - return func() error { - return self.c.Helpers().Diff.WithDiffModeCheck(func() error { +func (self *FilesController) GetOnRenderToMain() func() { + return func() { + self.c.Helpers().Diff.WithDiffModeCheck(func() { node := self.context().GetSelected() if node == nil { - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: self.c.Tr.DiffTitle, @@ -238,16 +238,18 @@ func (self *FilesController) GetOnRenderToMain() func() error { Task: types.NewRenderStringTask(self.c.Tr.NoChangedFiles), }, }) + return } if node.File != nil && node.File.HasInlineMergeConflicts { hasConflicts, err := self.c.Helpers().MergeConflicts.SetMergeState(node.GetPath()) if err != nil { - return err + return } if hasConflicts { - return self.c.Helpers().MergeConflicts.Render() + self.c.Helpers().MergeConflicts.Render() + return } } @@ -290,7 +292,7 @@ func (self *FilesController) GetOnRenderToMain() func() error { } } - return self.c.RenderToMainViews(refreshOpts) + self.c.RenderToMainViews(refreshOpts) }) } } @@ -454,7 +456,8 @@ func (self *FilesController) press(nodes []*filetree.FileNode) error { return err } - return self.context().HandleFocus(types.OnFocusOpts{}) + self.context().HandleFocus(types.OnFocusOpts{}) + return nil } func (self *FilesController) Context() types.Context { @@ -502,7 +505,8 @@ func (self *FilesController) EnterFile(opts types.OnFocusOpts) error { 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 { @@ -514,7 +518,8 @@ func (self *FilesController) toggleStagedAll() error { return err } - return self.context().HandleFocus(types.OnFocusOpts{}) + self.context().HandleFocus(types.OnFocusOpts{}) + return nil } func (self *FilesController) toggleStagedAllWithLock() error { @@ -596,13 +601,15 @@ func (self *FilesController) ignoreOrExcludeUntracked(node *filetree.FileNode, t func (self *FilesController) ignoreOrExcludeFile(node *filetree.FileNode, trText string, trPrompt string, trAction string, f func(string) error) error { if node.GetIsTracked() { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: trText, Prompt: trPrompt, HandleConfirm: func() error { return self.ignoreOrExcludeTracked(node, trAction, f) }, }) + + return nil } return self.ignoreOrExcludeUntracked(node, trAction, f) } @@ -655,7 +662,7 @@ func (self *FilesController) refresh() error { } func (self *FilesController) handleAmendCommitPress() error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.AmendLastCommitTitle, Prompt: self.c.Tr.SureToAmend, HandleConfirm: func() error { @@ -668,6 +675,8 @@ func (self *FilesController) handleAmendCommitPress() error { }) }, }) + + return nil } func (self *FilesController) handleStatusFilterPressed() error { @@ -954,7 +963,7 @@ func (self *FilesController) toggleTreeView() error { } func (self *FilesController) handleStashSave(stashFunc func(message string) error, action string) error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.StashChanges, HandleConfirm: func(stashComment string) error { self.c.LogAction(action) @@ -965,6 +974,8 @@ func (self *FilesController) handleStashSave(stashFunc func(message string) erro return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.STASH, types.FILES}}) }, }) + + return nil } func (self *FilesController) onClickMain(opts gocui.ViewMouseBindingOpts) error { diff --git a/pkg/gui/controllers/filtering_menu_action.go b/pkg/gui/controllers/filtering_menu_action.go index 9367c5bca12..0f0f9ceecf5 100644 --- a/pkg/gui/controllers/filtering_menu_action.go +++ b/pkg/gui/controllers/filtering_menu_action.go @@ -61,13 +61,15 @@ func (self *FilteringMenuAction) Call() error { menuItems = append(menuItems, &types.MenuItem{ Label: self.c.Tr.FilterPathOption, OnPress: func() error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ FindSuggestionsFunc: self.c.Helpers().Suggestions.GetFilePathSuggestionsFunc(), Title: self.c.Tr.EnterFileName, HandleConfirm: func(response string) error { return self.setFilteringPath(strings.TrimSpace(response)) }, }) + + return nil }, Tooltip: tooltip, }) @@ -75,13 +77,15 @@ func (self *FilteringMenuAction) Call() error { menuItems = append(menuItems, &types.MenuItem{ Label: self.c.Tr.FilterAuthorOption, OnPress: func() error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ FindSuggestionsFunc: self.c.Helpers().Suggestions.GetAuthorsSuggestionsFunc(), Title: self.c.Tr.EnterAuthor, HandleConfirm: func(response string) error { return self.setFilteringAuthor(strings.TrimSpace(response)) }, }) + + return nil }, Tooltip: tooltip, }) @@ -116,9 +120,7 @@ func (self *FilteringMenuAction) setFiltering() error { repoState.SetScreenMode(types.SCREEN_HALF) } - if err := self.c.Context().Push(self.c.Contexts().LocalCommits); err != nil { - return err - } + self.c.Context().Push(self.c.Contexts().LocalCommits) return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() error { self.c.Contexts().LocalCommits.SetSelection(0) diff --git a/pkg/gui/controllers/git_flow_controller.go b/pkg/gui/controllers/git_flow_controller.go index 7c3e45603cf..bdc0cad321d 100644 --- a/pkg/gui/controllers/git_flow_controller.go +++ b/pkg/gui/controllers/git_flow_controller.go @@ -54,7 +54,7 @@ func (self *GitFlowController) handleCreateGitFlowMenu(branch *models.Branch) er return func() error { title := utils.ResolvePlaceholderString(self.c.Tr.NewGitFlowBranchPrompt, map[string]string{"branchType": branchType}) - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: title, HandleConfirm: func(name string) error { self.c.LogAction(self.c.Tr.Actions.GitFlowStart) @@ -63,6 +63,8 @@ func (self *GitFlowController) handleCreateGitFlowMenu(branch *models.Branch) er ) }, }) + + return nil } } diff --git a/pkg/gui/controllers/helpers/bisect_helper.go b/pkg/gui/controllers/helpers/bisect_helper.go index aa8bb50230a..ccb77bfa35a 100644 --- a/pkg/gui/controllers/helpers/bisect_helper.go +++ b/pkg/gui/controllers/helpers/bisect_helper.go @@ -13,7 +13,7 @@ func NewBisectHelper(c *HelperCommon) *BisectHelper { } func (self *BisectHelper) Reset() error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Bisect.ResetTitle, Prompt: self.c.Tr.Bisect.ResetPrompt, HandleConfirm: func() error { @@ -25,6 +25,8 @@ func (self *BisectHelper) Reset() error { return self.PostBisectCommandRefresh() }, }) + + return nil } func (self *BisectHelper) PostBisectCommandRefresh() error { diff --git a/pkg/gui/controllers/helpers/branches_helper.go b/pkg/gui/controllers/helpers/branches_helper.go index c07d1d72bb0..635b94f20e0 100644 --- a/pkg/gui/controllers/helpers/branches_helper.go +++ b/pkg/gui/controllers/helpers/branches_helper.go @@ -32,7 +32,7 @@ func (self *BranchesHelper) ConfirmDeleteRemote(remoteName string, branchName st "upstream": remoteName, }, ) - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: title, Prompt: prompt, HandleConfirm: func() error { @@ -45,6 +45,8 @@ func (self *BranchesHelper) ConfirmDeleteRemote(remoteName string, branchName st }) }, }) + + return nil } func ShortBranchName(fullBranchName string) string { diff --git a/pkg/gui/controllers/helpers/cherry_pick_helper.go b/pkg/gui/controllers/helpers/cherry_pick_helper.go index 6742bd79a77..93637073e89 100644 --- a/pkg/gui/controllers/helpers/cherry_pick_helper.go +++ b/pkg/gui/controllers/helpers/cherry_pick_helper.go @@ -63,7 +63,7 @@ func (self *CherryPickHelper) CopyRange(commitsList []*models.Commit, context ty // HandlePasteCommits begins a cherry-pick rebase with the commits the user has copied. // Only to be called from the branch commits controller func (self *CherryPickHelper) Paste() error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.CherryPick, Prompt: self.c.Tr.SureCherryPick, HandleConfirm: func() error { @@ -108,6 +108,8 @@ func (self *CherryPickHelper) Paste() error { }) }, }) + + return nil } func (self *CherryPickHelper) CanPaste() bool { diff --git a/pkg/gui/controllers/helpers/commits_helper.go b/pkg/gui/controllers/helpers/commits_helper.go index ff6ba2e8033..b0f954c2ec7 100644 --- a/pkg/gui/controllers/helpers/commits_helper.go +++ b/pkg/gui/controllers/helpers/commits_helper.go @@ -101,10 +101,7 @@ func (self *CommitsHelper) SwitchToEditor() error { return err } - err = self.CloseCommitMessagePanel() - if err != nil { - return err - } + self.CloseCommitMessagePanel() return self.c.Contexts().CommitMessage.SwitchToEditor(filepath) } @@ -134,11 +131,9 @@ type OpenCommitMessagePanelOpts struct { InitialMessage string } -func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOpts) error { +func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOpts) { onConfirm := func(summary string, description string) error { - if err := self.CloseCommitMessagePanel(); err != nil { - return err - } + self.CloseCommitMessagePanel() return opts.OnConfirm(summary, description) } @@ -154,7 +149,7 @@ func (self *CommitsHelper) OpenCommitMessagePanel(opts *OpenCommitMessagePanelOp self.UpdateCommitPanelView(opts.InitialMessage) - return self.c.Context().Push(self.c.Contexts().CommitMessage) + self.c.Context().Push(self.c.Contexts().CommitMessage) } func (self *CommitsHelper) OnCommitSuccess() { @@ -179,7 +174,7 @@ func (self *CommitsHelper) HandleCommitConfirm() error { return nil } -func (self *CommitsHelper) CloseCommitMessagePanel() error { +func (self *CommitsHelper) CloseCommitMessagePanel() { if self.c.Contexts().CommitMessage.GetPreserveMessage() { message := self.JoinCommitMessageAndUnwrappedDescription() @@ -193,7 +188,7 @@ func (self *CommitsHelper) CloseCommitMessagePanel() error { self.c.Views().CommitMessage.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 { @@ -235,7 +230,7 @@ func (self *CommitsHelper) OpenCommitMenu(suggestionFunc func(string) []*types.S } func (self *CommitsHelper) addCoAuthor(suggestionFunc func(string) []*types.Suggestion) error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.AddCoAuthorPromptTitle, FindSuggestionsFunc: suggestionFunc, HandleConfirm: func(value string) error { @@ -245,6 +240,8 @@ func (self *CommitsHelper) addCoAuthor(suggestionFunc func(string) []*types.Sugg return nil }, }) + + return nil } func (self *CommitsHelper) pasteCommitMessageFromClipboard() error { @@ -262,7 +259,7 @@ func (self *CommitsHelper) pasteCommitMessageFromClipboard() error { } // Confirm before overwriting the commit message - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.PasteCommitMessageFromClipboard, Prompt: self.c.Tr.SurePasteCommitMessage, HandleConfirm: func() error { @@ -270,4 +267,6 @@ func (self *CommitsHelper) pasteCommitMessageFromClipboard() error { return nil }, }) + + return nil } diff --git a/pkg/gui/controllers/helpers/confirmation_helper.go b/pkg/gui/controllers/helpers/confirmation_helper.go index 43e2302721d..3ffdae6a179 100644 --- a/pkg/gui/controllers/helpers/confirmation_helper.go +++ b/pkg/gui/controllers/helpers/confirmation_helper.go @@ -28,9 +28,7 @@ func (self *ConfirmationHelper) wrappedConfirmationFunction(cancel goContext.Can return func() error { cancel() - if err := self.c.Context().Pop(); err != nil { - return err - } + self.c.Context().Pop() if function != nil { if err := function(); err != nil { @@ -163,7 +161,7 @@ func (self *ConfirmationHelper) prepareConfirmationPanel( self.c.Views().Confirmation.Wrap = !opts.Editable self.c.Views().Confirmation.FgColor = theme.GocuiDefaultTextColor self.c.Views().Confirmation.Mask = runeForMask(opts.Mask) - _ = self.c.Views().Confirmation.SetOrigin(0, 0) + self.c.Views().Confirmation.SetOrigin(0, 0) suggestionsContext := self.c.Contexts().Suggestions suggestionsContext.State.FindSuggestions = opts.FindSuggestionsFunc @@ -185,7 +183,7 @@ func runeForMask(mask bool) rune { return 0 } -func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts types.CreatePopupPanelOpts) error { +func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts types.CreatePopupPanelOpts) { self.c.Mutexes().PopupMutex.Lock() defer self.c.Mutexes().PopupMutex.Unlock() @@ -199,7 +197,7 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ if currentPopupOpts != nil && !currentPopupOpts.HasLoader { self.c.Log.Error("ignoring create popup panel because a popup panel is already open") cancel() - return nil + return } // remove any previous keybindings @@ -232,7 +230,7 @@ func (self *ConfirmationHelper) CreatePopupPanel(ctx goContext.Context, opts typ self.c.State().GetRepoState().SetCurrentPopupOpts(&opts) - return self.c.Context().Push(self.c.Contexts().Confirmation) + self.c.Context().Push(self.c.Contexts().Confirmation) } func underlineLinks(text string) string { @@ -366,11 +364,11 @@ func (self *ConfirmationHelper) layoutMenuPrompt(contentWidth int) int { // We need to rerender to give the menu context a chance to update its // non-model items, and reinitialize the data it uses for converting // between view index and model index. - _ = self.c.Contexts().Menu.HandleRender() + self.c.Contexts().Menu.HandleRender() // Then we need to refocus to ensure the cursor is in the right place in // the view. - _ = self.c.Contexts().Menu.HandleFocus(types.OnFocusOpts{}) + self.c.Contexts().Menu.HandleFocus(types.OnFocusOpts{}) } return len(promptLines) } diff --git a/pkg/gui/controllers/helpers/credentials_helper.go b/pkg/gui/controllers/helpers/credentials_helper.go index 6050c9be8a0..2e6dcc25eb0 100644 --- a/pkg/gui/controllers/helpers/credentials_helper.go +++ b/pkg/gui/controllers/helpers/credentials_helper.go @@ -27,7 +27,7 @@ func (self *CredentialsHelper) PromptUserForCredential(passOrUname oscommands.Cr self.c.OnUIThread(func() error { title, mask := self.getTitleAndMask(passOrUname) - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: title, Mask: mask, HandleConfirm: func(input string) error { @@ -41,6 +41,8 @@ func (self *CredentialsHelper) PromptUserForCredential(passOrUname oscommands.Cr return nil }, }) + + return nil }) return ch diff --git a/pkg/gui/controllers/helpers/diff_helper.go b/pkg/gui/controllers/helpers/diff_helper.go index 42cdb99dd40..0a8c85aa991 100644 --- a/pkg/gui/controllers/helpers/diff_helper.go +++ b/pkg/gui/controllers/helpers/diff_helper.go @@ -81,7 +81,7 @@ func (self *DiffHelper) ExitDiffMode() error { return self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC}) } -func (self *DiffHelper) RenderDiff() error { +func (self *DiffHelper) RenderDiff() { args := self.DiffArgs() cmdObj := self.c.Git().Diff.DiffCmdObj(args) task := types.NewRunPtyTask(cmdObj.GetCmd()) @@ -91,7 +91,7 @@ func (self *DiffHelper) RenderDiff() error { "git diff "+strings.Join(args, " "), ) - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: "Diff", @@ -141,12 +141,12 @@ func (self *DiffHelper) currentlySelectedFilename() string { return "" } -func (self *DiffHelper) WithDiffModeCheck(f func() error) error { +func (self *DiffHelper) WithDiffModeCheck(f func()) { if self.c.Modes().Diffing.Active() { - return self.RenderDiff() + self.RenderDiff() + } else { + f() } - - return f() } func (self *DiffHelper) IgnoringWhitespaceSubTitle() string { diff --git a/pkg/gui/controllers/helpers/fixup_helper.go b/pkg/gui/controllers/helpers/fixup_helper.go index 8fc94243d8f..4d4709cf815 100644 --- a/pkg/gui/controllers/helpers/fixup_helper.go +++ b/pkg/gui/controllers/helpers/fixup_helper.go @@ -137,17 +137,20 @@ func (self *FixupHelper) HandleFindBaseCommitForFixupPress() error { } 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 { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.FindBaseCommitForFixup, Prompt: self.c.Tr.HunksWithOnlyAddedLinesWarning, HandleConfirm: func() error { return doIt() }, }) + + return nil } return doIt() diff --git a/pkg/gui/controllers/helpers/inline_status_helper.go b/pkg/gui/controllers/helpers/inline_status_helper.go index cc9da86ea41..2e1cf29e0c1 100644 --- a/pkg/gui/controllers/helpers/inline_status_helper.go +++ b/pkg/gui/controllers/helpers/inline_status_helper.go @@ -151,7 +151,7 @@ func (self *InlineStatusHelper) stop(opts InlineStatusOpts) { func (self *InlineStatusHelper) renderContext(contextKey types.ContextKey) { self.c.OnUIThread(func() error { - _ = self.c.ContextForKey(contextKey).HandleRender() + self.c.ContextForKey(contextKey).HandleRender() return nil }) } diff --git a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go index 21284201cca..5b3b91772c2 100644 --- a/pkg/gui/controllers/helpers/merge_and_rebase_helper.go +++ b/pkg/gui/controllers/helpers/merge_and_rebase_helper.go @@ -202,7 +202,8 @@ func (self *MergeAndRebaseHelper) PromptForConflictHandling() error { { Label: self.c.Tr.ViewConflictsMenuItem, OnPress: func() error { - return self.c.Context().Push(self.c.Contexts().Files) + self.c.Context().Push(self.c.Contexts().Files) + return nil }, }, { @@ -220,13 +221,15 @@ func (self *MergeAndRebaseHelper) PromptForConflictHandling() error { func (self *MergeAndRebaseHelper) AbortMergeOrRebaseWithConfirm() error { // prompt user to confirm that they want to abort, then do it mode := self.workingTreeStateNoun() - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: fmt.Sprintf(self.c.Tr.AbortTitle, mode), Prompt: fmt.Sprintf(self.c.Tr.AbortPrompt, mode), HandleConfirm: func() error { return self.genericMergeCommand(REBASE_OPTION_ABORT) }, }) + + return nil } func (self *MergeAndRebaseHelper) workingTreeStateNoun() string { @@ -243,7 +246,7 @@ func (self *MergeAndRebaseHelper) workingTreeStateNoun() string { // PromptToContinueRebase asks the user if they want to continue the rebase/merge that's in progress func (self *MergeAndRebaseHelper) PromptToContinueRebase() error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Continue, Prompt: self.c.Tr.ConflictsResolved, HandleConfirm: func() error { @@ -263,7 +266,7 @@ func (self *MergeAndRebaseHelper) PromptToContinueRebase() error { root := self.c.Contexts().Files.FileTreeViewModel.GetRoot() if root.GetHasUnstagedChanges() { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Continue, Prompt: self.c.Tr.UnstagedFilesAfterConflictsResolved, HandleConfirm: func() error { @@ -275,11 +278,15 @@ func (self *MergeAndRebaseHelper) PromptToContinueRebase() error { return self.genericMergeCommand(REBASE_OPTION_CONTINUE) }, }) + + return nil } return self.genericMergeCommand(REBASE_OPTION_CONTINUE) }, }) + + return nil } func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error { @@ -346,7 +353,8 @@ func (self *MergeAndRebaseHelper) RebaseOntoRef(ref string) error { if err = self.ResetMarkedBaseCommit(); err != nil { return err } - return self.c.Context().Push(self.c.Contexts().LocalCommits) + self.c.Context().Push(self.c.Contexts().LocalCommits) + return nil }, }, { diff --git a/pkg/gui/controllers/helpers/merge_conflicts_helper.go b/pkg/gui/controllers/helpers/merge_conflicts_helper.go index cdf1d449708..d1f705be986 100644 --- a/pkg/gui/controllers/helpers/merge_conflicts_helper.go +++ b/pkg/gui/controllers/helpers/merge_conflicts_helper.go @@ -62,7 +62,7 @@ func (self *MergeConflictsHelper) EscapeMerge() error { // files context over it. // So long as both places call OnUIThread, we're fine. 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 }) @@ -93,14 +93,15 @@ 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 { return self.c.Contexts().MergeConflicts } -func (self *MergeConflictsHelper) Render() error { +func (self *MergeConflictsHelper) Render() { content := self.context().GetContentToRender() var task types.UpdateTask @@ -111,7 +112,7 @@ func (self *MergeConflictsHelper) Render() error { task = types.NewRenderStringWithScrollTask(content, 0, originY) } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().MergeConflicts, Main: &types.ViewUpdateOpts{ Task: task, diff --git a/pkg/gui/controllers/helpers/patch_building_helper.go b/pkg/gui/controllers/helpers/patch_building_helper.go index df6e34216f8..df107ed9b6e 100644 --- a/pkg/gui/controllers/helpers/patch_building_helper.go +++ b/pkg/gui/controllers/helpers/patch_building_helper.go @@ -33,8 +33,8 @@ func (self *PatchBuildingHelper) ValidateNormalWorkingTreeState() (bool, error) } // takes us from the patch building panel back to the commit files panel -func (self *PatchBuildingHelper) Escape() error { - return self.c.Context().Pop() +func (self *PatchBuildingHelper) Escape() { + self.c.Context().Pop() } // 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() if self.c.Context().CurrentStatic().GetKind() != types.SIDE_CONTEXT { - if err := self.Escape(); err != nil { - return err - } + self.Escape() } if err := self.c.Refresh(types.RefreshOptions{ @@ -57,27 +55,28 @@ func (self *PatchBuildingHelper) Reset() error { return self.c.PostRefreshUpdate(self.c.Context().Current()) } -func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpts) error { +func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpts) { selectedLineIdx := -1 if opts.ClickedWindowName == "main" { selectedLineIdx = opts.ClickedViewLineIdx } if !self.c.Git().Patch.PatchBuilder.Active() { - return self.Escape() + self.Escape() + return } // get diff from commit file that's currently selected path := self.c.Contexts().CommitFiles.GetSelectedPath() if path == "" { - return nil + return } from, to := self.c.Contexts().CommitFiles.GetFromAndToForDiff() from, reverse := self.c.Modes().Diffing.GetFromAndReverseArgsForDiff(from) diff, err := self.c.Git().WorkingTree.ShowFileDiff(from, to, reverse, path, true) if err != nil { - return err + return } secondaryDiff := self.c.Git().Patch.PatchBuilder.RenderPatchForFile(patch.RenderPatchForFileOpts{ @@ -94,14 +93,15 @@ func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpt state := patch_exploring.NewState(diff, selectedLineIdx, oldState, self.c.Log) context.SetState(state) if state == nil { - return self.Escape() + self.Escape() + return } mainContent := context.GetContentToRender(true) self.c.Contexts().CustomPatchBuilder.FocusSelection() - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().PatchBuilding, Main: &types.ViewUpdateOpts{ Task: types.NewRenderStringWithoutScrollTask(mainContent), diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 01be0d26787..2a0c93f52e5 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -175,12 +175,12 @@ func (self *RefreshHelper) Refresh(options types.RefreshOptions) error { if scopeSet.Includes(types.STAGING) { refresh("staging", func() { fileWg.Wait() - _ = self.stagingHelper.RefreshStagingPanel(types.OnFocusOpts{}) + self.stagingHelper.RefreshStagingPanel(types.OnFocusOpts{}) }) } if scopeSet.Includes(types.PATCH_BUILDING) { - refresh("patch building", func() { _ = self.patchBuildingHelper.RefreshPatchBuildingPanel(types.OnFocusOpts{}) }) + refresh("patch building", func() { self.patchBuildingHelper.RefreshPatchBuildingPanel(types.OnFocusOpts{}) }) } if scopeSet.Includes(types.MERGE_CONFLICTS) || scopeSet.Includes(types.FILES) { @@ -469,9 +469,7 @@ func (self *RefreshHelper) refreshBranches(refreshWorktrees bool, keepBranchSele }, func() { self.c.OnUIThread(func() error { - if err := self.c.Contexts().Branches.HandleRender(); err != nil { - self.c.Log.Error(err) - } + self.c.Contexts().Branches.HandleRender() self.refreshStatus() return nil }) @@ -504,9 +502,7 @@ func (self *RefreshHelper) refreshBranches(refreshWorktrees bool, keepBranchSele // Need to re-render the commits view because the visualization of local // branch heads might have changed self.c.Mutexes().LocalCommitsMutex.Lock() - if err := self.c.Contexts().LocalCommits.HandleRender(); err != nil { - self.c.Log.Error(err) - } + self.c.Contexts().LocalCommits.HandleRender() self.c.Mutexes().LocalCommitsMutex.Unlock() self.refreshStatus() diff --git a/pkg/gui/controllers/helpers/refs_helper.go b/pkg/gui/controllers/helpers/refs_helper.go index 067688307a0..8332174dcb9 100644 --- a/pkg/gui/controllers/helpers/refs_helper.go +++ b/pkg/gui/controllers/helpers/refs_helper.go @@ -78,8 +78,8 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions // offer to autostash changes self.c.OnUIThread(func() error { // (Before showing the prompt, render again to remove the inline status) - _ = self.c.Contexts().Branches.HandleRender() - return self.c.Confirm(types.ConfirmOpts{ + self.c.Contexts().Branches.HandleRender() + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.AutoStashTitle, Prompt: self.c.Tr.AutoStashPrompt, HandleConfirm: func() error { @@ -97,6 +97,8 @@ func (self *RefsHelper) CheckoutRef(ref string, options types.CheckoutRefOptions }) }, }) + + return nil }) return nil } @@ -115,9 +117,7 @@ func (self *RefsHelper) CheckoutRemoteBranch(fullBranchName string, localBranchN // Switch to the branches context _before_ starting to check out the // branch, so that we see the inline status if self.c.Context().Current() != self.c.Contexts().Branches { - if err := self.c.Context().Push(self.c.Contexts().Branches); err != nil { - return err - } + self.c.Context().Push(self.c.Contexts().Branches) } return self.CheckoutRef(branchName, types.CheckoutRefOptions{}) } @@ -285,9 +285,7 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest refresh := func() error { if self.c.Context().Current() != self.c.Contexts().Branches { - if err := self.c.Context().Push(self.c.Contexts().Branches); err != nil { - return err - } + self.c.Context().Push(self.c.Contexts().Branches) } self.c.Contexts().LocalCommits.SetSelection(0) @@ -296,7 +294,7 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest return self.c.Refresh(types.RefreshOptions{Mode: types.BLOCK_UI, KeepBranchSelectionIndex: true}) } - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: message, InitialContent: suggestedBranchName, HandleConfirm: func(response string) error { @@ -309,7 +307,7 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest if err := newBranchFunc(newBranchName, from); err != nil { if IsSwitchBranchUncommitedChangesError(err) { // offer to autostash changes - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.AutoStashTitle, Prompt: self.c.Tr.AutoStashPrompt, HandleConfirm: func() error { @@ -329,6 +327,8 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest return refreshError }, }) + + return nil } return err @@ -337,6 +337,8 @@ func (self *RefsHelper) NewBranch(from string, fromFormattedName string, suggest return refresh() }, }) + + return nil } // SanitizedBranchName will remove all spaces in favor of a dash "-" to meet diff --git a/pkg/gui/controllers/helpers/search_helper.go b/pkg/gui/controllers/helpers/search_helper.go index 554c87af1de..74467b02cfb 100644 --- a/pkg/gui/controllers/helpers/search_helper.go +++ b/pkg/gui/controllers/helpers/search_helper.go @@ -41,9 +41,7 @@ func (self *SearchHelper) OpenFilterPrompt(context types.IFilterableContext) err self.OnPromptContentChanged("") promptView.RenderTextArea() - if err := self.c.Context().Push(self.c.Contexts().Search); err != nil { - return err - } + self.c.Context().Push(self.c.Contexts().Search) return self.c.ResetKeybindings() } @@ -60,9 +58,7 @@ func (self *SearchHelper) OpenSearchPrompt(context types.ISearchableContext) err promptView.ClearTextArea() promptView.RenderTextArea() - if err := self.c.Context().Push(self.c.Contexts().Search); err != nil { - return err - } + self.c.Context().Push(self.c.Contexts().Search) return self.c.ResetKeybindings() } @@ -115,11 +111,11 @@ func (self *SearchHelper) Confirm() error { var err error switch state.SearchType() { case types.SearchTypeFilter: - err = self.ConfirmFilter() + self.ConfirmFilter() case types.SearchTypeSearch: err = self.ConfirmSearch() case types.SearchTypeNone: - err = self.c.Context().Pop() + self.c.Context().Pop() } if err != nil { @@ -129,14 +125,14 @@ func (self *SearchHelper) Confirm() error { 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 state := self.searchState() context, ok := state.Context.(types.IFilterableContext) if !ok { self.c.Log.Warnf("Context %s is not filterable", state.Context.GetKey()) - return nil + return } self.OnPromptContentChanged(self.promptContent()) @@ -145,7 +141,7 @@ func (self *SearchHelper) ConfirmFilter() error { context.GetSearchHistory().Push(filterString) } - return self.c.Context().Pop() + self.c.Context().Pop() } func (self *SearchHelper) ConfirmSearch() error { @@ -163,9 +159,7 @@ func (self *SearchHelper) ConfirmSearch() error { context.GetSearchHistory().Push(searchString) } - if err := self.c.Context().Pop(); err != nil { - return err - } + self.c.Context().Pop() return context.GetView().Search(searchString, modelSearchResults(context)) } @@ -188,9 +182,7 @@ func modelSearchResults(context types.ISearchableContext) []gocui.SearchPosition func (self *SearchHelper) CancelPrompt() error { self.Cancel() - if err := self.c.Context().Pop(); err != nil { - return err - } + self.c.Context().Pop() return self.c.ResetKeybindings() } @@ -237,7 +229,7 @@ func (self *SearchHelper) OnPromptContentChanged(searchString string) { switch context := state.Context.(type) { case types.IFilterableContext: context.SetSelection(0) - _ = context.GetView().SetOriginY(0) + context.GetView().SetOriginY(0) context.SetFilter(searchString, self.c.UserConfig().Gui.UseFuzzySearch()) _ = self.c.PostRefreshUpdate(context) case types.ISearchableContext: @@ -253,7 +245,7 @@ func (self *SearchHelper) ReApplyFilter(context types.Context) { state := self.searchState() if context == state.Context { filterableContext.SetSelection(0) - _ = filterableContext.GetView().SetOriginY(0) + filterableContext.GetView().SetOriginY(0) } filterableContext.ReApplyFilter(self.c.UserConfig().Gui.UseFuzzySearch()) } diff --git a/pkg/gui/controllers/helpers/staging_helper.go b/pkg/gui/controllers/helpers/staging_helper.go index 5643e47e8c5..d7b20252561 100644 --- a/pkg/gui/controllers/helpers/staging_helper.go +++ b/pkg/gui/controllers/helpers/staging_helper.go @@ -19,14 +19,14 @@ func NewStagingHelper( } // NOTE: used from outside this file -func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) error { +func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) { secondaryFocused := self.secondaryStagingFocused() mainFocused := self.mainStagingFocused() // this method could be called when the staging panel is not being used, // in which case we don't want to do anything. if !mainFocused && !secondaryFocused { - return nil + return } mainSelectedLineIdx := -1 @@ -49,7 +49,8 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) erro } if file == nil || (!file.HasUnstagedChanges && !file.HasStagedChanges) { - return self.handleStagingEscape() + self.handleStagingEscape() + return } mainDiff := self.c.Git().WorkingTree.WorktreeFileDiff(file, true, false) @@ -79,15 +80,18 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) erro secondaryContext.GetMutex().Unlock() if mainState == nil && secondaryState == nil { - return self.handleStagingEscape() + self.handleStagingEscape() + return } if mainState == nil && !secondaryFocused { - return self.c.Context().Push(secondaryContext, focusOpts) + self.c.Context().Push(secondaryContext, focusOpts) + return } if secondaryState == nil && secondaryFocused { - return self.c.Context().Push(mainContext, focusOpts) + self.c.Context().Push(mainContext, focusOpts) + return } if secondaryFocused { @@ -96,7 +100,7 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) erro self.c.Contexts().Staging.FocusSelection() } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Staging, Main: &types.ViewUpdateOpts{ Task: types.NewRenderStringWithoutScrollTask(mainContent), @@ -109,8 +113,8 @@ func (self *StagingHelper) RefreshStagingPanel(focusOpts types.OnFocusOpts) erro }) } -func (self *StagingHelper) handleStagingEscape() error { - return self.c.Context().Push(self.c.Contexts().Files) +func (self *StagingHelper) handleStagingEscape() { + self.c.Context().Push(self.c.Contexts().Files) } func (self *StagingHelper) secondaryStagingFocused() bool { diff --git a/pkg/gui/controllers/helpers/sub_commits_helper.go b/pkg/gui/controllers/helpers/sub_commits_helper.go index 805aca5f1b9..a7f9cec8a02 100644 --- a/pkg/gui/controllers/helpers/sub_commits_helper.go +++ b/pkg/gui/controllers/helpers/sub_commits_helper.go @@ -72,5 +72,6 @@ func (self *SubCommitsHelper) ViewSubCommits(opts ViewSubCommitsOpts) error { return err } - return self.c.Context().Push(self.c.Contexts().SubCommits) + self.c.Context().Push(self.c.Contexts().SubCommits) + return nil } diff --git a/pkg/gui/controllers/helpers/tags_helper.go b/pkg/gui/controllers/helpers/tags_helper.go index 8725eb05449..aa6ff7740ae 100644 --- a/pkg/gui/controllers/helpers/tags_helper.go +++ b/pkg/gui/controllers/helpers/tags_helper.go @@ -52,19 +52,21 @@ func (self *TagsHelper) OpenCreateTagPrompt(ref string, onCreate func()) error { "confirmKey": self.c.UserConfig().Keybinding.Universal.Confirm, }, ) - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.ForceTag, Prompt: prompt, HandleConfirm: func() error { return doCreateTag(tagName, description, true) }, }) - } else { - return doCreateTag(tagName, description, false) + + return nil } + + return doCreateTag(tagName, description, false) } - return self.commitsHelper.OpenCommitMessagePanel( + self.commitsHelper.OpenCommitMessagePanel( &OpenCommitMessagePanelOpts{ CommitIndex: context.NoCommitIndex, InitialMessage: "", @@ -74,4 +76,6 @@ func (self *TagsHelper) OpenCreateTagPrompt(ref string, onCreate func()) error { OnConfirm: onConfirm, }, ) + + return nil } diff --git a/pkg/gui/controllers/helpers/update_helper.go b/pkg/gui/controllers/helpers/update_helper.go index e01bae3c6f6..4491b433058 100644 --- a/pkg/gui/controllers/helpers/update_helper.go +++ b/pkg/gui/controllers/helpers/update_helper.go @@ -75,7 +75,8 @@ func (self *UpdateHelper) onUpdateFinish(err error) error { ) return errors.New(errMessage) } - return self.c.Alert(self.c.Tr.UpdateCompletedTitle, self.c.Tr.UpdateCompleted) + self.c.Alert(self.c.Tr.UpdateCompletedTitle, self.c.Tr.UpdateCompleted) + return nil }) return nil @@ -88,7 +89,7 @@ func (self *UpdateHelper) showUpdatePrompt(newVersion string) error { }, ) - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.UpdateAvailableTitle, Prompt: message, HandleConfirm: func() error { @@ -96,4 +97,6 @@ func (self *UpdateHelper) showUpdatePrompt(newVersion string) error { return nil }, }) + + return nil } diff --git a/pkg/gui/controllers/helpers/upstream_helper.go b/pkg/gui/controllers/helpers/upstream_helper.go index ea3187ed89b..c5d6ebe5b61 100644 --- a/pkg/gui/controllers/helpers/upstream_helper.go +++ b/pkg/gui/controllers/helpers/upstream_helper.go @@ -47,12 +47,14 @@ func (self *UpstreamHelper) ParseUpstream(upstream string) (string, string, erro } func (self *UpstreamHelper) promptForUpstream(initialContent string, onConfirm func(string) error) error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.EnterUpstream, InitialContent: initialContent, FindSuggestionsFunc: self.getRemoteBranchesSuggestionsFunc(" "), HandleConfirm: onConfirm, }) + + return nil } func (self *UpstreamHelper) PromptForUpstreamWithInitialContent(currentBranch *models.Branch, onConfirm func(string) error) error { diff --git a/pkg/gui/controllers/helpers/working_tree_helper.go b/pkg/gui/controllers/helpers/working_tree_helper.go index 96baaeebe14..a6033083a44 100644 --- a/pkg/gui/controllers/helpers/working_tree_helper.go +++ b/pkg/gui/controllers/helpers/working_tree_helper.go @@ -72,7 +72,7 @@ func (self *WorkingTreeHelper) FileForSubmodule(submodule *models.SubmoduleConfi } func (self *WorkingTreeHelper) OpenMergeTool() error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.MergeToolTitle, Prompt: self.c.Tr.MergeToolPrompt, HandleConfirm: func() error { @@ -82,11 +82,13 @@ func (self *WorkingTreeHelper) OpenMergeTool() error { ) }, }) + + return nil } func (self *WorkingTreeHelper) HandleCommitPressWithMessage(initialMessage string) error { return self.WithEnsureCommitableFiles(func() error { - return self.commitsHelper.OpenCommitMessagePanel( + self.commitsHelper.OpenCommitMessagePanel( &OpenCommitMessagePanelOpts{ CommitIndex: context.NoCommitIndex, InitialMessage: initialMessage, @@ -97,6 +99,8 @@ func (self *WorkingTreeHelper) HandleCommitPressWithMessage(initialMessage strin OnSwitchToEditor: self.switchFromCommitMessagePanelToEditor, }, ) + + return nil }) } @@ -185,7 +189,7 @@ func (self *WorkingTreeHelper) WithEnsureCommitableFiles(handler func() error) e } func (self *WorkingTreeHelper) promptToStageAllAndRetry(retry func() error) error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.NoFilesStagedTitle, Prompt: self.c.Tr.NoFilesStagedPrompt, HandleConfirm: func() error { @@ -200,6 +204,8 @@ func (self *WorkingTreeHelper) promptToStageAllAndRetry(retry func() error) erro return retry() }, }) + + return nil } // for when you need to refetch files before continuing an action. Runs synchronously. diff --git a/pkg/gui/controllers/helpers/worktree_helper.go b/pkg/gui/controllers/helpers/worktree_helper.go index 7c763e0fb61..6f28692d35a 100644 --- a/pkg/gui/controllers/helpers/worktree_helper.go +++ b/pkg/gui/controllers/helpers/worktree_helper.go @@ -63,8 +63,8 @@ func (self *WorktreeHelper) NewWorktree() error { branch := self.refsHelper.GetCheckedOutRef() currentBranchName := branch.RefName() - f := func(detached bool) error { - return self.c.Prompt(types.PromptOpts{ + f := func(detached bool) { + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.NewWorktreeBase, InitialContent: currentBranchName, FindSuggestionsFunc: self.suggestionsHelper.GetRefsSuggestionsFunc(), @@ -84,13 +84,15 @@ func (self *WorktreeHelper) NewWorktree() error { { LabelColumns: []string{utils.ResolvePlaceholderString(self.c.Tr.CreateWorktreeFrom, placeholders)}, OnPress: func() error { - return f(false) + f(false) + return nil }, }, { LabelColumns: []string{utils.ResolvePlaceholderString(self.c.Tr.CreateWorktreeFromDetached, placeholders)}, OnPress: func() error { - return f(true) + f(true) + return nil }, }, }, @@ -114,7 +116,7 @@ func (self *WorktreeHelper) NewWorktreeCheckout(base string, canCheckoutBase boo }) } - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.NewWorktreePath, HandleConfirm: func(path string) error { opts.Path = path @@ -126,7 +128,7 @@ func (self *WorktreeHelper) NewWorktreeCheckout(base string, canCheckoutBase boo if canCheckoutBase { title := utils.ResolvePlaceholderString(self.c.Tr.NewBranchNameLeaveBlank, map[string]string{"default": base}) // prompt for the new branch name where a blank means we just check out the branch - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: title, HandleConfirm: func(branchName string) error { opts.Branch = branchName @@ -134,9 +136,11 @@ func (self *WorktreeHelper) NewWorktreeCheckout(base string, canCheckoutBase boo return f() }, }) + + return nil } else { // prompt for the new branch name where a blank means we just check out the branch - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.NewBranchName, HandleConfirm: func(branchName string) error { if branchName == "" { @@ -148,9 +152,13 @@ func (self *WorktreeHelper) NewWorktreeCheckout(base string, canCheckoutBase boo return f() }, }) + + return nil } }, }) + + return nil } func (self *WorktreeHelper) Switch(worktree *models.Worktree, contextKey types.ContextKey) error { @@ -178,7 +186,7 @@ func (self *WorktreeHelper) Remove(worktree *models.Worktree, force bool) error }, ) - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: title, Prompt: message, HandleConfirm: func() error { @@ -199,6 +207,8 @@ func (self *WorktreeHelper) Remove(worktree *models.Worktree, force bool) error }) }, }) + + return nil } func (self *WorktreeHelper) Detach(worktree *models.Worktree) error { diff --git a/pkg/gui/controllers/jump_to_side_window_controller.go b/pkg/gui/controllers/jump_to_side_window_controller.go index 2ef74d9572f..f6917f5b4b6 100644 --- a/pkg/gui/controllers/jump_to_side_window_controller.go +++ b/pkg/gui/controllers/jump_to_side_window_controller.go @@ -55,6 +55,7 @@ func (self *JumpToSideWindowController) goToSideWindow(window string) func() err context := self.c.Helpers().Window.GetContextForWindow(window) - return self.c.Context().Push(context) + self.c.Context().Push(context) + return nil } } diff --git a/pkg/gui/controllers/list_controller.go b/pkg/gui/controllers/list_controller.go index 7e51c504d0d..d78e8c3567c 100644 --- a/pkg/gui/controllers/list_controller.go +++ b/pkg/gui/controllers/list_controller.go @@ -54,7 +54,7 @@ func (self *ListController) HandleScrollUp() error { scrollHeight := self.c.UserConfig().Gui.ScrollHeight self.context.GetViewTrait().ScrollUp(scrollHeight) if self.context.RenderOnlyVisibleLines() { - return self.context.HandleRender() + self.context.HandleRender() } return nil @@ -64,7 +64,7 @@ func (self *ListController) HandleScrollDown() error { scrollHeight := self.c.UserConfig().Gui.ScrollHeight self.context.GetViewTrait().ScrollDown(scrollHeight) if self.context.RenderOnlyVisibleLines() { - return self.context.HandleRender() + self.context.HandleRender() } return nil @@ -73,7 +73,8 @@ func (self *ListController) HandleScrollDown() error { func (self *ListController) scrollHorizontal(scrollFunc func()) error { scrollFunc() - return self.context.HandleFocus(types.OnFocusOpts{}) + self.context.HandleFocus(types.OnFocusOpts{}) + return nil } func (self *ListController) handleLineChange(change int) error { @@ -115,7 +116,7 @@ func (self *ListController) handleLineChangeAux(f func(int), change int) error { } if cursorMoved || rangeBefore != rangeAfter { - return self.context.HandleFocus(types.OnFocusOpts{}) + self.context.HandleFocus(types.OnFocusOpts{}) } return nil @@ -142,7 +143,8 @@ func (self *ListController) HandleToggleRangeSelect() error { list.ToggleStickyRange() - return self.context.HandleFocus(types.OnFocusOpts{}) + self.context.HandleFocus(types.OnFocusOpts{}) + return nil } func (self *ListController) HandleRangeSelectDown() error { @@ -171,14 +173,13 @@ func (self *ListController) HandleClick(opts gocui.ViewMouseBindingOpts) error { if prevSelectedLineIdx == newSelectedLineIdx && alreadyFocused && self.context.GetOnClick() != nil { return self.context.GetOnClick()() } - return self.context.HandleFocus(types.OnFocusOpts{}) + self.context.HandleFocus(types.OnFocusOpts{}) + return nil } func (self *ListController) pushContextIfNotFocused() error { if !self.isFocused() { - if err := self.c.Context().Push(self.context); err != nil { - return err - } + self.c.Context().Push(self.context) } return nil diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index f0ca624c1a1..1e2d4c08efa 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -272,9 +272,9 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [ return bindings } -func (self *LocalCommitsController) GetOnRenderToMain() func() error { - return func() error { - return self.c.Helpers().Diff.WithDiffModeCheck(func() error { +func (self *LocalCommitsController) GetOnRenderToMain() func() { + return func() { + self.c.Helpers().Diff.WithDiffModeCheck(func() { var task types.UpdateTask commit := self.context().GetSelected() if commit == nil { @@ -294,7 +294,7 @@ func (self *LocalCommitsController) GetOnRenderToMain() func() error { task = self.c.Helpers().Diff.GetUpdateTaskForRenderingCommitsDiff(commit, refRange) } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: "Patch", @@ -325,7 +325,7 @@ func (self *LocalCommitsController) squashDown(selectedCommits []*models.Commit, return self.updateTodos(todo.Squash, selectedCommits) } - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Squash, Prompt: self.c.Tr.SureSquashThisCommit, HandleConfirm: func() error { @@ -335,6 +335,8 @@ func (self *LocalCommitsController) squashDown(selectedCommits []*models.Commit, }) }, }) + + return nil } func (self *LocalCommitsController) fixup(selectedCommits []*models.Commit, startIdx int, endIdx int) error { @@ -342,7 +344,7 @@ func (self *LocalCommitsController) fixup(selectedCommits []*models.Commit, star return self.updateTodos(todo.Fixup, selectedCommits) } - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Fixup, Prompt: self.c.Tr.SureFixupThisCommit, HandleConfirm: func() error { @@ -352,6 +354,8 @@ func (self *LocalCommitsController) fixup(selectedCommits []*models.Commit, star }) }, }) + + return nil } func (self *LocalCommitsController) reword(commit *models.Commit) error { @@ -362,7 +366,7 @@ func (self *LocalCommitsController) reword(commit *models.Commit) error { if self.c.UserConfig().Git.Commit.AutoWrapCommitMessage { commitMessage = helpers.TryRemoveHardLineBreaks(commitMessage, self.c.UserConfig().Git.Commit.AutoWrapWidth) } - return self.c.Helpers().Commits.OpenCommitMessagePanel( + self.c.Helpers().Commits.OpenCommitMessagePanel( &helpers.OpenCommitMessagePanelOpts{ CommitIndex: self.context().GetSelectedLineIdx(), InitialMessage: commitMessage, @@ -373,6 +377,8 @@ func (self *LocalCommitsController) reword(commit *models.Commit) error { OnSwitchToEditor: self.switchFromCommitMessagePanelToEditor, }, ) + + return nil } func (self *LocalCommitsController) switchFromCommitMessagePanelToEditor(filepath string) error { @@ -442,13 +448,15 @@ func (self *LocalCommitsController) doRewordEditor() error { func (self *LocalCommitsController) rewordEditor(commit *models.Commit) error { if self.c.UserConfig().Gui.SkipRewordInEditorWarning { return self.doRewordEditor() - } else { - return self.c.Confirm(types.ConfirmOpts{ - Title: self.c.Tr.RewordInEditorTitle, - Prompt: self.c.Tr.RewordInEditorPrompt, - HandleConfirm: self.doRewordEditor, - }) } + + self.c.Confirm(types.ConfirmOpts{ + Title: self.c.Tr.RewordInEditorTitle, + Prompt: self.c.Tr.RewordInEditorPrompt, + HandleConfirm: self.doRewordEditor, + }) + + return nil } func (self *LocalCommitsController) drop(selectedCommits []*models.Commit, startIdx int, endIdx int) error { @@ -460,7 +468,7 @@ func (self *LocalCommitsController) drop(selectedCommits []*models.Commit, start nonUpdateRefTodos := groupedTodos[false] if len(updateRefTodos) > 0 { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DropCommitTitle, Prompt: self.c.Tr.DropUpdateRefPrompt, HandleConfirm: func() error { @@ -481,12 +489,14 @@ func (self *LocalCommitsController) drop(selectedCommits []*models.Commit, start return self.updateTodos(todo.Drop, nonUpdateRefTodos) }, }) + + return nil } return self.updateTodos(todo.Drop, selectedCommits) } - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DropCommitTitle, Prompt: self.c.Tr.DropCommitPrompt, HandleConfirm: func() error { @@ -496,6 +506,8 @@ func (self *LocalCommitsController) drop(selectedCommits []*models.Commit, start }) }, }) + + return nil } func (self *LocalCommitsController) edit(selectedCommits []*models.Commit) error { @@ -680,7 +692,7 @@ func (self *LocalCommitsController) moveUp(selectedCommits []*models.Commit, sta func (self *LocalCommitsController) amendTo(commit *models.Commit) error { if self.isSelectedHeadCommit() { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.AmendCommitTitle, Prompt: self.c.Tr.AmendCommitPrompt, HandleConfirm: func() error { @@ -692,9 +704,11 @@ func (self *LocalCommitsController) amendTo(commit *models.Commit) error { }) }, }) + + return nil } - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.AmendCommitTitle, Prompt: self.c.Tr.AmendCommitPrompt, HandleConfirm: func() error { @@ -707,6 +721,8 @@ func (self *LocalCommitsController) amendTo(commit *models.Commit) error { }) }, }) + + return nil } func (self *LocalCommitsController) canAmendRange(commits []*models.Commit, start, end int) *types.DisabledReason { @@ -761,7 +777,7 @@ func (self *LocalCommitsController) resetAuthor(start, end int) error { } func (self *LocalCommitsController) setAuthor(start, end int) error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.SetAuthorPromptTitle, FindSuggestionsFunc: self.c.Helpers().Suggestions.GetAuthorsSuggestionsFunc(), HandleConfirm: func(value string) error { @@ -775,10 +791,12 @@ func (self *LocalCommitsController) setAuthor(start, end int) error { }) }, }) + + return nil } func (self *LocalCommitsController) addCoAuthor(start, end int) error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.AddCoAuthorPromptTitle, FindSuggestionsFunc: self.c.Helpers().Suggestions.GetAuthorsSuggestionsFunc(), HandleConfirm: func(value string) error { @@ -791,30 +809,34 @@ func (self *LocalCommitsController) addCoAuthor(start, end int) error { }) }, }) + + return nil } func (self *LocalCommitsController) revert(commit *models.Commit) error { if commit.IsMerge() { return self.createRevertMergeCommitMenu(commit) - } else { - return self.c.Confirm(types.ConfirmOpts{ - Title: self.c.Tr.Actions.RevertCommit, - Prompt: utils.ResolvePlaceholderString( - self.c.Tr.ConfirmRevertCommit, - map[string]string{ - "selectedCommit": commit.ShortHash(), - }), - HandleConfirm: func() error { - self.c.LogAction(self.c.Tr.Actions.RevertCommit) - return self.c.WithWaitingStatusSync(self.c.Tr.RevertingStatus, func() error { - if err := self.c.Git().Commit.Revert(commit.Hash); err != nil { - return err - } - return self.afterRevertCommit() - }) - }, - }) } + + self.c.Confirm(types.ConfirmOpts{ + Title: self.c.Tr.Actions.RevertCommit, + Prompt: utils.ResolvePlaceholderString( + self.c.Tr.ConfirmRevertCommit, + map[string]string{ + "selectedCommit": commit.ShortHash(), + }), + HandleConfirm: func() error { + self.c.LogAction(self.c.Tr.Actions.RevertCommit) + return self.c.WithWaitingStatusSync(self.c.Tr.RevertingStatus, func() error { + if err := self.c.Git().Commit.Revert(commit.Hash); err != nil { + return err + } + return self.afterRevertCommit() + }) + }, + }) + + return nil } func (self *LocalCommitsController) createRevertMergeCommitMenu(commit *models.Commit) error { @@ -911,7 +933,7 @@ func (self *LocalCommitsController) createAmendCommit(commit *models.Commit, inc commitMessage = helpers.TryRemoveHardLineBreaks(commitMessage, self.c.UserConfig().Git.Commit.AutoWrapWidth) } originalSubject, _, _ := strings.Cut(commitMessage, "\n") - return self.c.Helpers().Commits.OpenCommitMessagePanel( + self.c.Helpers().Commits.OpenCommitMessagePanel( &helpers.OpenCommitMessagePanelOpts{ CommitIndex: self.context().GetSelectedLineIdx(), InitialMessage: commitMessage, @@ -932,6 +954,8 @@ func (self *LocalCommitsController) createAmendCommit(commit *models.Commit, inc OnSwitchToEditor: nil, }, ) + + return nil } func (self *LocalCommitsController) squashFixupCommits() error { @@ -1175,8 +1199,8 @@ func (self *LocalCommitsController) handleOpenLogMenu() error { }) } -func (self *LocalCommitsController) GetOnFocus() func(types.OnFocusOpts) error { - return func(types.OnFocusOpts) error { +func (self *LocalCommitsController) GetOnFocus() func(types.OnFocusOpts) { + return func(types.OnFocusOpts) { context := self.context() if context.GetSelectedLineIdx() > COMMIT_THRESHOLD && context.GetLimitCommits() { context.SetLimitCommits(false) @@ -1184,8 +1208,6 @@ func (self *LocalCommitsController) GetOnFocus() func(types.OnFocusOpts) error { return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}}) }) } - - return nil } } diff --git a/pkg/gui/controllers/menu_controller.go b/pkg/gui/controllers/menu_controller.go index 61bd3b9601f..f1a17f651be 100644 --- a/pkg/gui/controllers/menu_controller.go +++ b/pkg/gui/controllers/menu_controller.go @@ -59,13 +59,12 @@ func (self *MenuController) GetOnClick() func() error { return self.withItemGraceful(self.press) } -func (self *MenuController) GetOnFocus() func(types.OnFocusOpts) error { - return func(types.OnFocusOpts) error { +func (self *MenuController) GetOnFocus() func(types.OnFocusOpts) { + return func(types.OnFocusOpts) { selectedMenuItem := self.context().GetSelected() if selectedMenuItem != nil { self.c.Views().Tooltip.SetContent(self.c.Helpers().Confirmation.TooltipForMenuItem(selectedMenuItem)) } - return nil } } @@ -79,7 +78,8 @@ func (self *MenuController) close() error { return nil } - return self.c.Context().Pop() + self.c.Context().Pop() + return nil } func (self *MenuController) context() *context.MenuContext { diff --git a/pkg/gui/controllers/merge_conflicts_controller.go b/pkg/gui/controllers/merge_conflicts_controller.go index 06bfda94f05..28cf1bab4d3 100644 --- a/pkg/gui/controllers/merge_conflicts_controller.go +++ b/pkg/gui/controllers/merge_conflicts_controller.go @@ -147,27 +147,21 @@ func (self *MergeConflictsController) GetMouseKeybindings(opts types.Keybindings } } -func (self *MergeConflictsController) GetOnFocus() func(types.OnFocusOpts) error { - return func(types.OnFocusOpts) error { +func (self *MergeConflictsController) GetOnFocus() func(types.OnFocusOpts) { + return func(types.OnFocusOpts) { self.c.Views().MergeConflicts.Wrap = false - if err := self.c.Helpers().MergeConflicts.Render(); err != nil { - return err - } + self.c.Helpers().MergeConflicts.Render() self.context().SetSelectedLineRange() - - return nil } } -func (self *MergeConflictsController) GetOnFocusLost() func(types.OnFocusLostOpts) error { - return func(types.OnFocusLostOpts) error { +func (self *MergeConflictsController) GetOnFocusLost() func(types.OnFocusLostOpts) { + return func(types.OnFocusLostOpts) { self.context().SetUserScrolling(false) self.context().GetState().ResetConflictSelection() self.c.Views().MergeConflicts.Wrap = true - - return nil } } @@ -194,7 +188,8 @@ func (self *MergeConflictsController) context() *context.MergeConflictsContext { } func (self *MergeConflictsController) Escape() error { - return self.c.Context().Pop() + self.c.Context().Pop() + return nil } func (self *MergeConflictsController) HandleEditFile() error { @@ -331,7 +326,8 @@ func (self *MergeConflictsController) withRenderAndFocus(f func() error) func() return err } - return self.context().RenderAndFocus() + self.context().RenderAndFocus() + return nil }) } diff --git a/pkg/gui/controllers/patch_building_controller.go b/pkg/gui/controllers/patch_building_controller.go index dbbdb8bebc0..9b6568016dd 100644 --- a/pkg/gui/controllers/patch_building_controller.go +++ b/pkg/gui/controllers/patch_building_controller.go @@ -62,24 +62,22 @@ func (self *PatchBuildingController) GetMouseKeybindings(opts types.KeybindingsO return []*gocui.ViewMouseBinding{} } -func (self *PatchBuildingController) GetOnFocus() func(types.OnFocusOpts) error { - return func(opts types.OnFocusOpts) error { +func (self *PatchBuildingController) GetOnFocus() func(types.OnFocusOpts) { + return func(opts types.OnFocusOpts) { // no need to change wrap on the secondary view because it can't be interacted with self.c.Views().PatchBuilding.Wrap = false - return self.c.Helpers().PatchBuilding.RefreshPatchBuildingPanel(opts) + self.c.Helpers().PatchBuilding.RefreshPatchBuildingPanel(opts) } } -func (self *PatchBuildingController) GetOnFocusLost() func(types.OnFocusLostOpts) error { - return func(opts types.OnFocusLostOpts) error { +func (self *PatchBuildingController) GetOnFocusLost() func(types.OnFocusLostOpts) { + return func(opts types.OnFocusLostOpts) { self.c.Views().PatchBuilding.Wrap = true if self.c.Git().Patch.PatchBuilder.IsEmpty() { self.c.Git().Patch.PatchBuilder.Reset() } - - return nil } } @@ -165,5 +163,6 @@ func (self *PatchBuildingController) Escape() error { return self.c.PostRefreshUpdate(context) } - return self.c.Helpers().PatchBuilding.Escape() + self.c.Helpers().PatchBuilding.Escape() + return nil } diff --git a/pkg/gui/controllers/patch_explorer_controller.go b/pkg/gui/controllers/patch_explorer_controller.go index 999dc15e97e..3e5e1539d26 100644 --- a/pkg/gui/controllers/patch_explorer_controller.go +++ b/pkg/gui/controllers/patch_explorer_controller.go @@ -150,10 +150,12 @@ func (self *PatchExplorerController) GetMouseKeybindings(opts types.KeybindingsO 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(), ClickedViewLineIdx: opts.Y, }) + + return nil }, }, { @@ -300,7 +302,8 @@ func (self *PatchExplorerController) withRenderAndFocus(f func() error) func() e return err } - return self.context.RenderAndFocus(self.isFocused()) + self.context.RenderAndFocus(self.isFocused()) + return nil }) } diff --git a/pkg/gui/controllers/quit_actions.go b/pkg/gui/controllers/quit_actions.go index 76226033123..c85ab069c68 100644 --- a/pkg/gui/controllers/quit_actions.go +++ b/pkg/gui/controllers/quit_actions.go @@ -26,26 +26,30 @@ func (self *QuitActions) quitAux() error { } if self.c.UserConfig().ConfirmOnQuit { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: "", Prompt: self.c.Tr.ConfirmQuit, HandleConfirm: func() error { return gocui.ErrQuit }, }) + + return nil } return gocui.ErrQuit } func (self *QuitActions) confirmQuitDuringUpdate() error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.ConfirmQuitDuringUpdateTitle, Prompt: self.c.Tr.ConfirmQuitDuringUpdate, HandleConfirm: func() error { return gocui.ErrQuit }, }) + + return nil } func (self *QuitActions) Escape() error { @@ -74,7 +78,8 @@ func (self *QuitActions) Escape() error { parentContext := currentContext.GetParentContext() if parentContext != nil { // 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() { diff --git a/pkg/gui/controllers/reflog_commits_controller.go b/pkg/gui/controllers/reflog_commits_controller.go index b4250f4c975..6ccc32a2b01 100644 --- a/pkg/gui/controllers/reflog_commits_controller.go +++ b/pkg/gui/controllers/reflog_commits_controller.go @@ -37,9 +37,9 @@ func (self *ReflogCommitsController) context() *context.ReflogCommitsContext { return self.c.Contexts().ReflogCommits } -func (self *ReflogCommitsController) GetOnRenderToMain() func() error { - return func() error { - return self.c.Helpers().Diff.WithDiffModeCheck(func() error { +func (self *ReflogCommitsController) GetOnRenderToMain() func() { + return func() { + self.c.Helpers().Diff.WithDiffModeCheck(func() { commit := self.context().GetSelected() var task types.UpdateTask if commit == nil { @@ -50,7 +50,7 @@ func (self *ReflogCommitsController) GetOnRenderToMain() func() error { task = types.NewRunPtyTask(cmdObj.GetCmd()) } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: "Reflog Entry", diff --git a/pkg/gui/controllers/remote_branches_controller.go b/pkg/gui/controllers/remote_branches_controller.go index c859ef3f63a..772baf4fa8c 100644 --- a/pkg/gui/controllers/remote_branches_controller.go +++ b/pkg/gui/controllers/remote_branches_controller.go @@ -105,9 +105,9 @@ func (self *RemoteBranchesController) GetKeybindings(opts types.KeybindingsOpts) } } -func (self *RemoteBranchesController) GetOnRenderToMain() func() error { - return func() error { - return self.c.Helpers().Diff.WithDiffModeCheck(func() error { +func (self *RemoteBranchesController) GetOnRenderToMain() func() { + return func() { + self.c.Helpers().Diff.WithDiffModeCheck(func() { var task types.UpdateTask remoteBranch := self.context().GetSelected() if remoteBranch == nil { @@ -117,7 +117,7 @@ func (self *RemoteBranchesController) GetOnRenderToMain() func() error { task = types.NewRunCommandTask(cmdObj.GetCmd()) } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: "Remote Branch", @@ -172,7 +172,7 @@ func (self *RemoteBranchesController) setAsUpstream(selectedBranch *models.Remot }, ) - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.SetUpstreamTitle, Prompt: message, HandleConfirm: func() error { @@ -184,6 +184,8 @@ func (self *RemoteBranchesController) setAsUpstream(selectedBranch *models.Remot return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}}) }, }) + + return nil } func (self *RemoteBranchesController) newLocalBranch(selectedBranch *models.RemoteBranch) error { diff --git a/pkg/gui/controllers/remotes_controller.go b/pkg/gui/controllers/remotes_controller.go index cf9c40b2215..dbae0e0b10d 100644 --- a/pkg/gui/controllers/remotes_controller.go +++ b/pkg/gui/controllers/remotes_controller.go @@ -87,9 +87,9 @@ func (self *RemotesController) context() *context.RemotesContext { return self.c.Contexts().Remotes } -func (self *RemotesController) GetOnRenderToMain() func() error { - return func() error { - return self.c.Helpers().Diff.WithDiffModeCheck(func() error { +func (self *RemotesController) GetOnRenderToMain() func() { + return func() { + self.c.Helpers().Diff.WithDiffModeCheck(func() { var task types.UpdateTask remote := self.context().GetSelected() if remote == nil { @@ -98,7 +98,7 @@ func (self *RemotesController) GetOnRenderToMain() func() error { task = types.NewRenderStringTask(fmt.Sprintf("%s\nUrls:\n%s", style.FgGreen.Sprint(remote.Name), strings.Join(remote.Urls, "\n"))) } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: "Remote", @@ -131,14 +131,15 @@ func (self *RemotesController) enter(remote *models.Remote) error { return err } - return self.c.Context().Push(remoteBranchesContext) + self.c.Context().Push(remoteBranchesContext) + return nil } func (self *RemotesController) add() error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.NewRemoteName, HandleConfirm: func(remoteName string) error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.NewRemoteUrl, HandleConfirm: func(remoteUrl string) error { self.c.LogAction(self.c.Tr.Actions.AddRemote) @@ -168,12 +169,16 @@ func (self *RemotesController) add() error { return self.fetch(self.c.Contexts().Remotes.GetSelected()) }, }) + + return nil }, }) + + return nil } func (self *RemotesController) remove(remote *models.Remote) error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.RemoveRemote, Prompt: self.c.Tr.RemoveRemotePrompt + " '" + remote.Name + "'?", HandleConfirm: func() error { @@ -185,6 +190,8 @@ func (self *RemotesController) remove(remote *models.Remote) error { return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}}) }, }) + + return nil } func (self *RemotesController) edit(remote *models.Remote) error { @@ -195,7 +202,7 @@ func (self *RemotesController) edit(remote *models.Remote) error { }, ) - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: editNameMessage, InitialContent: remote.Name, HandleConfirm: func(updatedRemoteName string) error { @@ -219,7 +226,7 @@ func (self *RemotesController) edit(remote *models.Remote) error { url = urls[0] } - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: editUrlMessage, InitialContent: url, HandleConfirm: func(updatedRemoteUrl string) error { @@ -230,8 +237,12 @@ func (self *RemotesController) edit(remote *models.Remote) error { return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.BRANCHES, types.REMOTES}}) }, }) + + return nil }, }) + + return nil } func (self *RemotesController) fetch(remote *models.Remote) error { diff --git a/pkg/gui/controllers/rename_similarity_threshold_controller.go b/pkg/gui/controllers/rename_similarity_threshold_controller.go index f90e32da09b..f602ca9d8b9 100644 --- a/pkg/gui/controllers/rename_similarity_threshold_controller.go +++ b/pkg/gui/controllers/rename_similarity_threshold_controller.go @@ -88,7 +88,8 @@ func (self *RenameSimilarityThresholdController) applyChange() error { case context.FILES_CONTEXT_KEY: return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.FILES}}) default: - return currentContext.HandleRenderToMain() + currentContext.HandleRenderToMain() + return nil } } diff --git a/pkg/gui/controllers/screen_mode_actions.go b/pkg/gui/controllers/screen_mode_actions.go index 2d0026793c5..2d4b1c8d04c 100644 --- a/pkg/gui/controllers/screen_mode_actions.go +++ b/pkg/gui/controllers/screen_mode_actions.go @@ -17,7 +17,8 @@ func (self *ScreenModeActions) Next() error { ), ) - return self.rerenderViewsWithScreenModeDependentContent() + self.rerenderViewsWithScreenModeDependentContent() + return nil } func (self *ScreenModeActions) Prev() error { @@ -28,31 +29,28 @@ func (self *ScreenModeActions) Prev() error { ), ) - return self.rerenderViewsWithScreenModeDependentContent() + self.rerenderViewsWithScreenModeDependentContent() + return nil } // these views need to be re-rendered when the screen mode changes. The commits view, // for example, will show authorship information in half and full screen mode. -func (self *ScreenModeActions) rerenderViewsWithScreenModeDependentContent() error { +func (self *ScreenModeActions) rerenderViewsWithScreenModeDependentContent() { for _, context := range self.c.Context().AllList() { if context.NeedsRerenderOnWidthChange() == types.NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_SCREEN_MODE_CHANGES { - if err := self.rerenderView(context.GetView()); err != nil { - return err - } + self.rerenderView(context.GetView()) } } - - return nil } -func (self *ScreenModeActions) rerenderView(view *gocui.View) error { +func (self *ScreenModeActions) rerenderView(view *gocui.View) { context, ok := self.c.Helpers().View.ContextForView(view.Name()) if !ok { self.c.Log.Errorf("no context found for view %s", view.Name()) - return nil + return } - return context.HandleRender() + context.HandleRender() } func nextIntInCycle(sl []types.WindowMaximisation, current types.WindowMaximisation) types.WindowMaximisation { diff --git a/pkg/gui/controllers/shell_command_action.go b/pkg/gui/controllers/shell_command_action.go index 943006ff926..01b6d1e3604 100644 --- a/pkg/gui/controllers/shell_command_action.go +++ b/pkg/gui/controllers/shell_command_action.go @@ -15,7 +15,7 @@ type ShellCommandAction struct { } func (self *ShellCommandAction) Call() error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.ShellCommand, FindSuggestionsFunc: self.GetShellCommandsHistorySuggestionsFunc(), AllowEditSuggestion: true, @@ -54,6 +54,8 @@ func (self *ShellCommandAction) Call() error { return nil }, }) + + return nil } func (self *ShellCommandAction) GetShellCommandsHistorySuggestionsFunc() func(string) []*types.Suggestion { diff --git a/pkg/gui/controllers/side_window_controller.go b/pkg/gui/controllers/side_window_controller.go index 5ad7766339b..799c87c2ee0 100644 --- a/pkg/gui/controllers/side_window_controller.go +++ b/pkg/gui/controllers/side_window_controller.go @@ -69,7 +69,8 @@ func (self *SideWindowController) previousSideWindow() error { 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 { @@ -92,5 +93,6 @@ func (self *SideWindowController) nextSideWindow() error { context := self.c.Helpers().Window.GetContextForWindow(newWindow) - return self.c.Context().Push(context) + self.c.Context().Push(context) + return nil } diff --git a/pkg/gui/controllers/snake_controller.go b/pkg/gui/controllers/snake_controller.go index 086e42e1d1a..08dddf1be9a 100644 --- a/pkg/gui/controllers/snake_controller.go +++ b/pkg/gui/controllers/snake_controller.go @@ -52,18 +52,16 @@ func (self *SnakeController) Context() types.Context { return self.c.Contexts().Snake } -func (self *SnakeController) GetOnFocus() func(types.OnFocusOpts) error { - return func(types.OnFocusOpts) error { +func (self *SnakeController) GetOnFocus() func(types.OnFocusOpts) { + return func(types.OnFocusOpts) { self.c.Helpers().Snake.StartGame() - return nil } } -func (self *SnakeController) GetOnFocusLost() func(types.OnFocusLostOpts) error { - return func(types.OnFocusLostOpts) error { +func (self *SnakeController) GetOnFocusLost() func(types.OnFocusLostOpts) { + return func(types.OnFocusLostOpts) { self.c.Helpers().Snake.ExitGame() self.c.Helpers().Window.MoveToTopOfWindow(self.c.Contexts().Submodules) - return nil } } @@ -75,5 +73,6 @@ func (self *SnakeController) SetDirection(direction snake.Direction) func() erro } func (self *SnakeController) Escape() error { - return self.c.Context().Push(self.c.Contexts().Submodules) + self.c.Context().Push(self.c.Contexts().Submodules) + return nil } diff --git a/pkg/gui/controllers/staging_controller.go b/pkg/gui/controllers/staging_controller.go index deac75a6c29..ca3cf20f72a 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -116,26 +116,25 @@ func (self *StagingController) GetMouseKeybindings(opts types.KeybindingsOpts) [ return []*gocui.ViewMouseBinding{} } -func (self *StagingController) GetOnFocus() func(types.OnFocusOpts) error { - return func(opts types.OnFocusOpts) error { +func (self *StagingController) GetOnFocus() func(types.OnFocusOpts) { + return func(opts types.OnFocusOpts) { self.c.Views().Staging.Wrap = false self.c.Views().StagingSecondary.Wrap = false - return self.c.Helpers().Staging.RefreshStagingPanel(opts) + self.c.Helpers().Staging.RefreshStagingPanel(opts) } } -func (self *StagingController) GetOnFocusLost() func(types.OnFocusLostOpts) error { - return func(opts types.OnFocusLostOpts) error { +func (self *StagingController) GetOnFocusLost() func(types.OnFocusLostOpts) { + return func(opts types.OnFocusLostOpts) { self.context.SetState(nil) if opts.NewContextKey != self.otherContext.GetKey() { self.c.Views().Staging.Wrap = true self.c.Views().StagingSecondary.Wrap = true - _ = self.c.Contexts().Staging.Render(false) - _ = self.c.Contexts().StagingSecondary.Render(false) + self.c.Contexts().Staging.Render(false) + self.c.Contexts().StagingSecondary.Render(false) } - return nil } } @@ -172,12 +171,13 @@ func (self *StagingController) Escape() error { return self.c.PostRefreshUpdate(self.context) } - return self.c.Context().Pop() + self.c.Context().Pop() + return nil } func (self *StagingController) TogglePanel() error { if self.otherContext.GetState() != nil { - return self.c.Context().Push(self.otherContext) + self.c.Context().Push(self.otherContext) } return nil @@ -191,11 +191,13 @@ func (self *StagingController) DiscardSelection() error { reset := func() error { return self.applySelectionAndRefresh(true) } if !self.staged && !self.c.UserConfig().Gui.SkipDiscardChangeWarning { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.DiscardChangeTitle, Prompt: self.c.Tr.DiscardChangePrompt, HandleConfirm: reset, }) + + return nil } return reset() diff --git a/pkg/gui/controllers/stash_controller.go b/pkg/gui/controllers/stash_controller.go index 9f6884b59b2..4d1cd723392 100644 --- a/pkg/gui/controllers/stash_controller.go +++ b/pkg/gui/controllers/stash_controller.go @@ -74,9 +74,9 @@ func (self *StashController) GetKeybindings(opts types.KeybindingsOpts) []*types return bindings } -func (self *StashController) GetOnRenderToMain() func() error { - return func() error { - return self.c.Helpers().Diff.WithDiffModeCheck(func() error { +func (self *StashController) GetOnRenderToMain() func() { + return func() { + self.c.Helpers().Diff.WithDiffModeCheck(func() { var task types.UpdateTask stashEntry := self.context().GetSelected() if stashEntry == nil { @@ -87,7 +87,7 @@ func (self *StashController) GetOnRenderToMain() func() error { ) } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: "Stash", @@ -118,13 +118,15 @@ func (self *StashController) handleStashApply(stashEntry *models.StashEntry) err return apply() } - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.StashApply, Prompt: self.c.Tr.SureApplyStashEntry, HandleConfirm: func() error { return apply() }, }) + + return nil } func (self *StashController) handleStashPop(stashEntry *models.StashEntry) error { @@ -142,17 +144,19 @@ func (self *StashController) handleStashPop(stashEntry *models.StashEntry) error return pop() } - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.StashPop, Prompt: self.c.Tr.SurePopStashEntry, HandleConfirm: func() error { return pop() }, }) + + return nil } func (self *StashController) handleStashDrop(stashEntry *models.StashEntry) error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.StashDrop, Prompt: self.c.Tr.SureDropStashEntry, HandleConfirm: func() error { @@ -165,6 +169,8 @@ func (self *StashController) handleStashDrop(stashEntry *models.StashEntry) erro return nil }, }) + + return nil } func (self *StashController) postStashRefresh() error { @@ -183,7 +189,7 @@ func (self *StashController) handleRenameStashEntry(stashEntry *models.StashEntr }, ) - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: message, InitialContent: stashEntry.Name, HandleConfirm: func(response string) error { @@ -198,4 +204,6 @@ func (self *StashController) handleRenameStashEntry(stashEntry *models.StashEntr return nil }, }) + + return nil } diff --git a/pkg/gui/controllers/status_controller.go b/pkg/gui/controllers/status_controller.go index ab7a6a0d507..c15e85f8c96 100644 --- a/pkg/gui/controllers/status_controller.go +++ b/pkg/gui/controllers/status_controller.go @@ -61,7 +61,7 @@ func (self *StatusController) GetKeybindings(opts types.KeybindingsOpts) []*type }, { Key: opts.GetKey(opts.Config.Status.AllBranchesLogGraph), - Handler: self.showAllBranchLogs, + Handler: func() error { self.showAllBranchLogs(); return nil }, Description: self.c.Tr.AllBranchesLogGraph, }, } @@ -79,15 +79,15 @@ func (self *StatusController) GetMouseKeybindings(opts types.KeybindingsOpts) [] } } -func (self *StatusController) GetOnRenderToMain() func() error { - return func() error { +func (self *StatusController) GetOnRenderToMain() func() { + return func() { switch self.c.UserConfig().Gui.StatusPanelView { case "dashboard": - return self.showDashboard() + self.showDashboard() case "allBranchesLog": - return self.showAllBranchLogs() + self.showAllBranchLogs() default: - return self.showDashboard() + self.showDashboard() } } } @@ -104,9 +104,7 @@ func (self *StatusController) onClick(opts gocui.ViewMouseBindingOpts) error { return nil } - if err := self.c.Context().Push(self.Context()); err != nil { - return err - } + self.c.Context().Push(self.Context()) upstreamStatus := utils.Decolorise(presentation.BranchStatus(currentBranch, types.ItemOperationNone, self.c.Tr, time.Now(), self.c.UserConfig())) repoName := self.c.Git().RepoPaths.RepoName() @@ -183,11 +181,11 @@ func (self *StatusController) editConfig() error { }) } -func (self *StatusController) showAllBranchLogs() error { +func (self *StatusController) showAllBranchLogs() { cmdObj := self.c.Git().Branch.AllBranchesLogCmdObj() task := types.NewRunPtyTask(cmdObj.GetCmd()) - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: self.c.Tr.LogTitle, @@ -196,7 +194,7 @@ func (self *StatusController) showAllBranchLogs() error { }) } -func (self *StatusController) showDashboard() error { +func (self *StatusController) showDashboard() { versionStr := "master" version, err := types.ParseVersionNumber(self.c.GetConfig().GetVersion()) if err == nil { @@ -218,7 +216,7 @@ func (self *StatusController) showDashboard() error { style.FgMagenta.Sprintf("Become a sponsor: %s", style.PrintSimpleHyperlink(constants.Links.Donate)), // caffeine ain't free }, "\n\n") + "\n" - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: self.c.Tr.StatusTitle, diff --git a/pkg/gui/controllers/sub_commits_controller.go b/pkg/gui/controllers/sub_commits_controller.go index 0f3ca990739..69024da8481 100644 --- a/pkg/gui/controllers/sub_commits_controller.go +++ b/pkg/gui/controllers/sub_commits_controller.go @@ -38,9 +38,9 @@ func (self *SubCommitsController) context() *context.SubCommitsContext { return self.c.Contexts().SubCommits } -func (self *SubCommitsController) GetOnRenderToMain() func() error { - return func() error { - return self.c.Helpers().Diff.WithDiffModeCheck(func() error { +func (self *SubCommitsController) GetOnRenderToMain() func() { + return func() { + self.c.Helpers().Diff.WithDiffModeCheck(func() { commit := self.context().GetSelected() var task types.UpdateTask if commit == nil { @@ -50,7 +50,7 @@ func (self *SubCommitsController) GetOnRenderToMain() func() error { task = self.c.Helpers().Diff.GetUpdateTaskForRenderingCommitsDiff(commit, refRange) } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: "Commit", @@ -62,8 +62,8 @@ func (self *SubCommitsController) GetOnRenderToMain() func() error { } } -func (self *SubCommitsController) GetOnFocus() func(types.OnFocusOpts) error { - return func(types.OnFocusOpts) error { +func (self *SubCommitsController) GetOnFocus() func(types.OnFocusOpts) { + return func(types.OnFocusOpts) { context := self.context() if context.GetSelectedLineIdx() > COMMIT_THRESHOLD && context.GetLimitCommits() { context.SetLimitCommits(false) @@ -71,7 +71,5 @@ func (self *SubCommitsController) GetOnFocus() func(types.OnFocusOpts) error { return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUB_COMMITS}}) }) } - - return nil } } diff --git a/pkg/gui/controllers/submodules_controller.go b/pkg/gui/controllers/submodules_controller.go index af729cea890..69c87b94c91 100644 --- a/pkg/gui/controllers/submodules_controller.go +++ b/pkg/gui/controllers/submodules_controller.go @@ -106,9 +106,9 @@ func (self *SubmodulesController) GetOnClick() func() error { return self.withItemGraceful(self.enter) } -func (self *SubmodulesController) GetOnRenderToMain() func() error { - return func() error { - return self.c.Helpers().Diff.WithDiffModeCheck(func() error { +func (self *SubmodulesController) GetOnRenderToMain() func() { + return func() { + self.c.Helpers().Diff.WithDiffModeCheck(func() { var task types.UpdateTask submodule := self.context().GetSelected() if submodule == nil { @@ -130,7 +130,7 @@ func (self *SubmodulesController) GetOnRenderToMain() func() error { } } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: "Submodule", @@ -146,16 +146,16 @@ func (self *SubmodulesController) enter(submodule *models.SubmoduleConfig) error } func (self *SubmodulesController) add() error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.NewSubmoduleUrl, HandleConfirm: func(submoduleUrl string) error { nameSuggestion := filepath.Base(strings.TrimSuffix(submoduleUrl, filepath.Ext(submoduleUrl))) - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.NewSubmoduleName, InitialContent: nameSuggestion, HandleConfirm: func(submoduleName string) error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: self.c.Tr.NewSubmodulePath, InitialContent: submoduleName, HandleConfirm: func(submodulePath string) error { @@ -170,14 +170,20 @@ func (self *SubmodulesController) add() error { }) }, }) + + return nil }, }) + + return nil }, }) + + return nil } func (self *SubmodulesController) editURL(submodule *models.SubmoduleConfig) error { - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: fmt.Sprintf(self.c.Tr.UpdateSubmoduleUrl, submodule.FullName()), InitialContent: submodule.Url, HandleConfirm: func(newUrl string) error { @@ -192,6 +198,8 @@ func (self *SubmodulesController) editURL(submodule *models.SubmoduleConfig) err }) }, }) + + return nil } func (self *SubmodulesController) init(submodule *models.SubmoduleConfig) error { @@ -270,7 +278,7 @@ func (self *SubmodulesController) update(submodule *models.SubmoduleConfig) erro } func (self *SubmodulesController) remove(submodule *models.SubmoduleConfig) error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.RemoveSubmodule, Prompt: fmt.Sprintf(self.c.Tr.RemoveSubmodulePrompt, submodule.FullName()), HandleConfirm: func() error { @@ -282,10 +290,13 @@ func (self *SubmodulesController) remove(submodule *models.SubmoduleConfig) erro return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUBMODULES, types.FILES}}) }, }) + + return nil } 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 { diff --git a/pkg/gui/controllers/suggestions_controller.go b/pkg/gui/controllers/suggestions_controller.go index 3908f526716..f6b3b04635a 100644 --- a/pkg/gui/controllers/suggestions_controller.go +++ b/pkg/gui/controllers/suggestions_controller.go @@ -72,13 +72,13 @@ func (self *SuggestionsController) GetKeybindings(opts types.KeybindingsOpts) [] func (self *SuggestionsController) switchToConfirmation() error { self.c.Views().Suggestions.Subtitle = "" 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) error { - return func(types.OnFocusLostOpts) error { +func (self *SuggestionsController) GetOnFocusLost() func(types.OnFocusLostOpts) { + return func(types.OnFocusLostOpts) { self.c.Helpers().Confirmation.DeactivateConfirmationPrompt() - return nil } } diff --git a/pkg/gui/controllers/switch_to_diff_files_controller.go b/pkg/gui/controllers/switch_to_diff_files_controller.go index 2faa000bb8e..3580e922795 100644 --- a/pkg/gui/controllers/switch_to_diff_files_controller.go +++ b/pkg/gui/controllers/switch_to_diff_files_controller.go @@ -91,7 +91,8 @@ func (self *SwitchToDiffFilesController) enter() error { return err } - return self.c.Context().Push(commitFilesContext) + self.c.Context().Push(commitFilesContext) + return nil } func (self *SwitchToDiffFilesController) canEnter() *types.DisabledReason { diff --git a/pkg/gui/controllers/sync_controller.go b/pkg/gui/controllers/sync_controller.go index b972894381c..a6140d9d015 100644 --- a/pkg/gui/controllers/sync_controller.go +++ b/pkg/gui/controllers/sync_controller.go @@ -214,7 +214,7 @@ func (self *SyncController) pushAux(currentBranch *models.Branch, opts pushOpts) if forcePushDisabled { return errors.New(self.c.Tr.UpdatesRejectedAndForcePushDisabled) } - _ = self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.ForcePush, Prompt: self.forcePushPrompt(), HandleConfirm: func() error { @@ -238,7 +238,7 @@ func (self *SyncController) requestToForcePush(currentBranch *models.Branch, opt return errors.New(self.c.Tr.ForcePushDisabled) } - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.ForcePush, Prompt: self.forcePushPrompt(), HandleConfirm: func() error { @@ -246,6 +246,8 @@ func (self *SyncController) requestToForcePush(currentBranch *models.Branch, opt return self.pushAux(currentBranch, opts) }, }) + + return nil } func (self *SyncController) forcePushPrompt() string { diff --git a/pkg/gui/controllers/tags_controller.go b/pkg/gui/controllers/tags_controller.go index 9c477be8ecd..372fa8e0a31 100644 --- a/pkg/gui/controllers/tags_controller.go +++ b/pkg/gui/controllers/tags_controller.go @@ -87,9 +87,9 @@ func (self *TagsController) GetKeybindings(opts types.KeybindingsOpts) []*types. return bindings } -func (self *TagsController) GetOnRenderToMain() func() error { - return func() error { - return self.c.Helpers().Diff.WithDiffModeCheck(func() error { +func (self *TagsController) GetOnRenderToMain() func() { + return func() { + self.c.Helpers().Diff.WithDiffModeCheck(func() { var task types.UpdateTask tag := self.context().GetSelected() if tag == nil { @@ -99,7 +99,7 @@ func (self *TagsController) GetOnRenderToMain() func() error { task = types.NewRunCommandTask(cmdObj.GetCmd()) } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: "Tag", @@ -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 { 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 { @@ -135,7 +136,7 @@ func (self *TagsController) remoteDelete(tag *models.Tag) error { }, ) - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: title, InitialContent: "origin", FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRemoteSuggestionsFunc(), @@ -154,7 +155,7 @@ func (self *TagsController) remoteDelete(tag *models.Tag) error { }, ) - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: confirmTitle, Prompt: confirmPrompt, HandleConfirm: func() error { @@ -168,8 +169,12 @@ func (self *TagsController) remoteDelete(tag *models.Tag) error { }) }, }) + + return nil }, }) + + return nil } func (self *TagsController) delete(tag *models.Tag) error { @@ -212,7 +217,7 @@ func (self *TagsController) push(tag *models.Tag) error { }, ) - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: title, InitialContent: "origin", FindSuggestionsFunc: self.c.Helpers().Suggestions.GetRemoteSuggestionsFunc(), @@ -223,7 +228,7 @@ func (self *TagsController) push(tag *models.Tag) error { // Render again to remove the inline status: self.c.OnUIThread(func() error { - _ = self.c.Contexts().Tags.HandleRender() + self.c.Contexts().Tags.HandleRender() return nil }) @@ -231,6 +236,8 @@ func (self *TagsController) push(tag *models.Tag) error { }) }, }) + + return nil } func (self *TagsController) createResetMenu(tag *models.Tag) error { diff --git a/pkg/gui/controllers/toggle_whitespace_action.go b/pkg/gui/controllers/toggle_whitespace_action.go index f5362ddf4b3..4d491e79b1d 100644 --- a/pkg/gui/controllers/toggle_whitespace_action.go +++ b/pkg/gui/controllers/toggle_whitespace_action.go @@ -28,5 +28,6 @@ func (self *ToggleWhitespaceAction) Call() error { self.c.GetAppState().IgnoreWhitespaceInDiffView = !self.c.GetAppState().IgnoreWhitespaceInDiffView self.c.SaveAppStateAndLogError() - return self.c.Context().CurrentSide().HandleFocus(types.OnFocusOpts{}) + self.c.Context().CurrentSide().HandleFocus(types.OnFocusOpts{}) + return nil } diff --git a/pkg/gui/controllers/undo_controller.go b/pkg/gui/controllers/undo_controller.go index 8bd44a86deb..d6f8ab256c8 100644 --- a/pkg/gui/controllers/undo_controller.go +++ b/pkg/gui/controllers/undo_controller.go @@ -89,7 +89,7 @@ func (self *UndoController) reflogUndo() error { switch action.kind { case COMMIT, REBASE: - return true, self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Actions.Undo, Prompt: fmt.Sprintf(self.c.Tr.HardResetAutostashPrompt, action.from), HandleConfirm: func() error { @@ -100,8 +100,10 @@ func (self *UndoController) reflogUndo() error { }) }, }) + return true, nil + case CHECKOUT: - return true, self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Actions.Undo, Prompt: fmt.Sprintf(self.c.Tr.CheckoutPrompt, action.from), HandleConfirm: func() error { @@ -112,6 +114,7 @@ func (self *UndoController) reflogUndo() error { }) }, }) + return true, nil case CURRENT_REBASE: // do nothing @@ -140,7 +143,7 @@ func (self *UndoController) reflogRedo() error { switch action.kind { case COMMIT, REBASE: - return true, self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Actions.Redo, Prompt: fmt.Sprintf(self.c.Tr.HardResetAutostashPrompt, action.to), HandleConfirm: func() error { @@ -151,9 +154,10 @@ func (self *UndoController) reflogRedo() error { }) }, }) + return true, nil case CHECKOUT: - return true, self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.Actions.Redo, Prompt: fmt.Sprintf(self.c.Tr.CheckoutPrompt, action.to), HandleConfirm: func() error { @@ -164,6 +168,8 @@ func (self *UndoController) reflogRedo() error { }) }, }) + return true, nil + case CURRENT_REBASE: // do nothing } @@ -242,7 +248,7 @@ func (self *UndoController) hardResetWithAutoStash(commitHash string, options ha dirtyWorkingTree := self.c.Helpers().WorkingTree.IsWorkingTreeDirty() if dirtyWorkingTree { // offer to autostash changes - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: self.c.Tr.AutoStashTitle, Prompt: self.c.Tr.AutoStashPrompt, HandleConfirm: func() error { @@ -262,6 +268,7 @@ func (self *UndoController) hardResetWithAutoStash(commitHash string, options ha }) }, }) + return nil } return self.c.WithWaitingStatus(options.WaitingStatus, func(gocui.Task) error { diff --git a/pkg/gui/controllers/workspace_reset_controller.go b/pkg/gui/controllers/workspace_reset_controller.go index 48ae6de368f..7e9d115a63b 100644 --- a/pkg/gui/controllers/workspace_reset_controller.go +++ b/pkg/gui/controllers/workspace_reset_controller.go @@ -188,7 +188,7 @@ func (self *FilesController) Explode(v *gocui.View, onDone func()) { style := styles[(i*len(styles)/max)%len(styles)] coloredImage := style.Sprint(image) self.c.OnUIThread(func() error { - _ = v.SetOrigin(0, 0) + v.SetOrigin(0, 0) v.SetContent(coloredImage) return nil }) diff --git a/pkg/gui/controllers/worktrees_controller.go b/pkg/gui/controllers/worktrees_controller.go index b9982c8c8d1..b81cc54672e 100644 --- a/pkg/gui/controllers/worktrees_controller.go +++ b/pkg/gui/controllers/worktrees_controller.go @@ -75,8 +75,8 @@ func (self *WorktreesController) GetKeybindings(opts types.KeybindingsOpts) []*t return bindings } -func (self *WorktreesController) GetOnRenderToMain() func() error { - return func() error { +func (self *WorktreesController) GetOnRenderToMain() func() { + return func() { var task types.UpdateTask worktree := self.context().GetSelected() if worktree == nil { @@ -102,7 +102,7 @@ func (self *WorktreesController) GetOnRenderToMain() func() error { task = types.NewRenderStringTask(builder.String()) } - return self.c.RenderToMainViews(types.RefreshMainOpts{ + self.c.RenderToMainViews(types.RefreshMainOpts{ Pair: self.c.MainViewPairs().Normal, Main: &types.ViewUpdateOpts{ Title: self.c.Tr.WorktreeTitle, diff --git a/pkg/gui/extras_panel.go b/pkg/gui/extras_panel.go index e3d8998d653..2319c813abd 100644 --- a/pkg/gui/extras_panel.go +++ b/pkg/gui/extras_panel.go @@ -17,9 +17,7 @@ func (gui *Gui) handleCreateExtrasMenuPanel() error { OnPress: func() error { currentContext := gui.c.Context().CurrentStatic() if gui.c.State().GetShowExtrasWindow() && currentContext.GetKey() == context.COMMAND_LOG_CONTEXT_KEY { - if err := gui.c.Context().Pop(); err != nil { - return err - } + gui.c.Context().Pop() } show := !gui.c.State().GetShowExtrasWindow() gui.c.State().SetShowExtrasWindow(show) @@ -40,7 +38,8 @@ func (gui *Gui) handleFocusCommandLog() error { gui.c.State().SetShowExtrasWindow(true) // TODO: is this necessary? Can't I just call 'return from context'? 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 { diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 8db1571c28a..4d5f625d9fe 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -393,9 +393,7 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.Context } } - if err := gui.c.Context().Push(contextToPush); err != nil { - return err - } + gui.c.Context().Push(contextToPush) return nil } @@ -507,10 +505,12 @@ func (gui *Gui) checkForChangedConfigsThatDontAutoReload(oldConfig *config.UserC "configs": strings.Join(changedConfigs, "\n"), }, ) - return gui.c.Confirm(types.ConfirmOpts{ + gui.c.Confirm(types.ConfirmOpts{ Title: gui.c.Tr.NonReloadableConfigWarningTitle, Prompt: message, }) + + return nil } // resetState reuses the repo state from our repo state map, if the repo was @@ -673,11 +673,11 @@ func NewGui( gui.PopupHandler = popup.NewPopupHandler( cmn, - func(ctx goContext.Context, opts types.CreatePopupPanelOpts) error { - return gui.helpers.Confirmation.CreatePopupPanel(ctx, opts) + func(ctx goContext.Context, opts types.CreatePopupPanelOpts) { + gui.helpers.Confirmation.CreatePopupPanel(ctx, opts) }, 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() }, gui.createMenu, func(message string, f func(gocui.Task) error) { gui.helpers.AppStatus.WithWaitingStatus(message, f) }, @@ -1003,12 +1003,14 @@ func (gui *Gui) showIntroPopupMessage() { return err } - return gui.c.Confirm(types.ConfirmOpts{ + gui.c.Confirm(types.ConfirmOpts{ Title: "", Prompt: gui.c.Tr.IntroPopupMessage, HandleConfirm: onConfirm, HandleClose: onConfirm, }) + + return nil }) } @@ -1068,12 +1070,13 @@ func (gui *Gui) showBreakingChangesMessage() { return nil } - return gui.c.Confirm(types.ConfirmOpts{ + gui.c.Confirm(types.ConfirmOpts{ Title: gui.Tr.BreakingChangesTitle, Prompt: gui.Tr.BreakingChangesMessage + "\n\n" + message, HandleConfirm: onConfirm, HandleClose: onConfirm, }) + return nil }) } } diff --git a/pkg/gui/gui_common.go b/pkg/gui/gui_common.go index b1540e6eb4c..08103e09a61 100644 --- a/pkg/gui/gui_common.go +++ b/pkg/gui/gui_common.go @@ -115,8 +115,8 @@ func (self *guiCommon) OnWorker(f func(gocui.Task) error) { self.gui.onWorker(f) } -func (self *guiCommon) RenderToMainViews(opts types.RefreshMainOpts) error { - return self.gui.refreshMainViews(opts) +func (self *guiCommon) RenderToMainViews(opts types.RefreshMainOpts) { + self.gui.refreshMainViews(opts) } func (self *guiCommon) MainViewPairs() types.MainViewPairs { diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index bdfed1df7ab..8439b9b7ad3 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -33,7 +33,7 @@ func (gui *Gui) outsideFilterMode(f func() error) func() error { func (gui *Gui) validateNotInFilterMode() bool { if gui.State.Modes.Filtering.Active() { - _ = gui.c.Confirm(types.ConfirmOpts{ + gui.c.Confirm(types.ConfirmOpts{ Title: gui.c.Tr.MustExitFilterModeTitle, Prompt: gui.c.Tr.MustExitFilterModePrompt, HandleConfirm: gui.helpers.Mode.ExitFilterMode, diff --git a/pkg/gui/layout.go b/pkg/gui/layout.go index 03cd07b60fd..9ee339d1123 100644 --- a/pkg/gui/layout.go +++ b/pkg/gui/layout.go @@ -177,9 +177,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { } for _, context := range contextsToRerender { - if err := context.HandleRender(); err != nil { - return err - } + context.HandleRender() } // here is a good place log some stuff @@ -225,9 +223,7 @@ func (gui *Gui) onInitialViewsCreationForRepo() error { } initialContext := gui.c.Context().Current() - if err := gui.c.Context().Activate(initialContext, types.OnFocusOpts{}); err != nil { - return err - } + gui.c.Context().Activate(initialContext, types.OnFocusOpts{}) return gui.loadNewRepo() } diff --git a/pkg/gui/main_panels.go b/pkg/gui/main_panels.go index 49d278399f1..54e3e1c0c94 100644 --- a/pkg/gui/main_panels.go +++ b/pkg/gui/main_panels.go @@ -58,7 +58,7 @@ func (gui *Gui) moveMainContextToTop(context types.Context) { } } -func (gui *Gui) RefreshMainView(opts *types.ViewUpdateOpts, context types.Context) error { +func (gui *Gui) RefreshMainView(opts *types.ViewUpdateOpts, context types.Context) { view := context.GetView() if opts.Title != "" { @@ -69,10 +69,7 @@ func (gui *Gui) RefreshMainView(opts *types.ViewUpdateOpts, context types.Contex if err := gui.runTaskForView(view, opts.Task); err != nil { gui.c.Log.Error(err) - return nil } - - return nil } func (gui *Gui) normalMainContextPair() types.MainContextPair { @@ -112,27 +109,23 @@ func (gui *Gui) allMainContextPairs() []types.MainContextPair { } } -func (gui *Gui) refreshMainViews(opts types.RefreshMainOpts) error { +func (gui *Gui) refreshMainViews(opts types.RefreshMainOpts) { // need to reset scroll positions of all other main views for _, pair := range gui.allMainContextPairs() { if pair.Main != opts.Pair.Main { - _ = pair.Main.GetView().SetOrigin(0, 0) + pair.Main.GetView().SetOrigin(0, 0) } if pair.Secondary != nil && pair.Secondary != opts.Pair.Secondary { - _ = pair.Secondary.GetView().SetOrigin(0, 0) + pair.Secondary.GetView().SetOrigin(0, 0) } } if opts.Main != nil { - if err := gui.RefreshMainView(opts.Main, opts.Pair.Main); err != nil { - return err - } + gui.RefreshMainView(opts.Main, opts.Pair.Main) } if opts.Secondary != nil { - if err := gui.RefreshMainView(opts.Secondary, opts.Pair.Secondary); err != nil { - return err - } + gui.RefreshMainView(opts.Secondary, opts.Pair.Secondary) } else if opts.Pair.Secondary != nil { opts.Pair.Secondary.GetView().Clear() } @@ -140,8 +133,6 @@ func (gui *Gui) refreshMainViews(opts types.RefreshMainOpts) error { gui.moveMainContextPairToTop(opts.Pair) gui.splitMainPanel(opts.Secondary != nil) - - return nil } func (gui *Gui) splitMainPanel(splitMainPanel bool) { diff --git a/pkg/gui/menu_panel.go b/pkg/gui/menu_panel.go index e21e3242842..5c2f8643f58 100644 --- a/pkg/gui/menu_panel.go +++ b/pkg/gui/menu_panel.go @@ -60,5 +60,6 @@ func (gui *Gui) createMenu(opts types.CreateMenuOptions) error { _ = gui.c.PostRefreshUpdate(gui.State.Contexts.Menu) // 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 } diff --git a/pkg/gui/popup/popup_handler.go b/pkg/gui/popup/popup_handler.go index 3f71644d301..8ea50de2b9b 100644 --- a/pkg/gui/popup/popup_handler.go +++ b/pkg/gui/popup/popup_handler.go @@ -12,9 +12,9 @@ import ( type PopupHandler struct { *common.Common - createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) error + createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) onErrorFn func() error - popContextFn func() error + popContextFn func() currentContextFn func() types.Context createMenuFn func(types.CreateMenuOptions) error withWaitingStatusFn func(message string, f func(gocui.Task) error) @@ -28,9 +28,9 @@ var _ types.IPopupHandler = &PopupHandler{} func NewPopupHandler( common *common.Common, - createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts) error, + createPopupPanelFn func(context.Context, types.CreatePopupPanelOpts), onErrorFn func() error, - popContextFn func() error, + popContextFn func(), currentContextFn func() types.Context, createMenuFn func(types.CreateMenuOptions) error, withWaitingStatusFn func(message string, f func(gocui.Task) error), @@ -86,15 +86,17 @@ func (self *PopupHandler) ErrorHandler(err error) error { return err } - return self.Alert(self.Tr.Error, coloredMessage) + self.Alert(self.Tr.Error, coloredMessage) + + return nil } -func (self *PopupHandler) Alert(title string, message string) error { - return self.Confirm(types.ConfirmOpts{Title: title, Prompt: message}) +func (self *PopupHandler) Alert(title string, message string) { + self.Confirm(types.ConfirmOpts{Title: title, Prompt: message}) } -func (self *PopupHandler) Confirm(opts types.ConfirmOpts) error { - return self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{ +func (self *PopupHandler) Confirm(opts types.ConfirmOpts) { + self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{ Title: opts.Title, Prompt: opts.Prompt, HandleConfirm: opts.HandleConfirm, @@ -102,8 +104,8 @@ func (self *PopupHandler) Confirm(opts types.ConfirmOpts) error { }) } -func (self *PopupHandler) Prompt(opts types.PromptOpts) error { - return self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{ +func (self *PopupHandler) Prompt(opts types.PromptOpts) { + self.createPopupPanelFn(context.Background(), types.CreatePopupPanelOpts{ Title: opts.Title, Prompt: opts.InitialContent, Editable: true, diff --git a/pkg/gui/services/custom_commands/handler_creator.go b/pkg/gui/services/custom_commands/handler_creator.go index 2c9e090f9b2..95de40a2e9a 100644 --- a/pkg/gui/services/custom_commands/handler_creator.go +++ b/pkg/gui/services/custom_commands/handler_creator.go @@ -118,7 +118,7 @@ func (self *HandlerCreator) inputPrompt(prompt *config.CustomCommandPrompt, wrap return err } - return self.c.Prompt(types.PromptOpts{ + self.c.Prompt(types.PromptOpts{ Title: prompt.Title, InitialContent: prompt.InitialValue, FindSuggestionsFunc: findSuggestionsFn, @@ -126,6 +126,8 @@ func (self *HandlerCreator) inputPrompt(prompt *config.CustomCommandPrompt, wrap return wrappedF(str) }, }) + + return nil } func (self *HandlerCreator) generateFindSuggestionsFunc(prompt *config.CustomCommandPrompt) (func(string) []*types.Suggestion, error) { @@ -183,11 +185,13 @@ func (self *HandlerCreator) getPresetSuggestionsFn(preset string) (func(string) } func (self *HandlerCreator) confirmPrompt(prompt *config.CustomCommandPrompt, handleConfirm func() error) error { - return self.c.Confirm(types.ConfirmOpts{ + self.c.Confirm(types.ConfirmOpts{ Title: prompt.Title, Prompt: prompt.Body, HandleConfirm: handleConfirm, }) + + return nil } func (self *HandlerCreator) menuPrompt(prompt *config.CustomCommandPrompt, wrappedF func(string) error) error { @@ -298,7 +302,7 @@ func (self *HandlerCreator) finalHandler(customCommand config.CustomCommand, ses return err } } - return self.c.Alert(title, output) + self.c.Alert(title, output) } return nil diff --git a/pkg/gui/tasks_adapter.go b/pkg/gui/tasks_adapter.go index 4fcba4b8327..62a53ae0b12 100644 --- a/pkg/gui/tasks_adapter.go +++ b/pkg/gui/tasks_adapter.go @@ -67,7 +67,7 @@ func (gui *Gui) newStringTaskWithScroll(view *gocui.View, str string, originX in f := func(tasks.TaskOpts) error { gui.c.SetViewContent(view, str) - _ = view.SetOrigin(originX, originY) + view.SetOrigin(originX, originY) return nil } @@ -119,16 +119,13 @@ func (gui *Gui) getManager(view *gocui.View) *tasks.ViewBufferManager { if linesHeight < originY { newOriginY := linesHeight - err := view.SetOrigin(0, newOriginY) - if err != nil { - panic(err) - } + view.SetOrigin(0, newOriginY) } view.FlushStaleCells() }, func() { - _ = view.SetOrigin(0, 0) + view.SetOrigin(0, 0) }, func() gocui.Task { return gui.c.GocuiGui().NewTask() diff --git a/pkg/gui/types/common.go b/pkg/gui/types/common.go index 9ae7f9ea05b..4dcafa0053b 100644 --- a/pkg/gui/types/common.go +++ b/pkg/gui/types/common.go @@ -45,7 +45,7 @@ type IGuiCommon interface { // allows rendering to main views (i.e. the ones to the right of the side panel) // in such a way that avoids concurrency issues when there are slow commands // to display the output of - RenderToMainViews(opts RefreshMainOpts) error + RenderToMainViews(opts RefreshMainOpts) // used purely for the sake of RenderToMainViews to provide the pair of main views we want to render to MainViewPairs() MainViewPairs @@ -120,11 +120,11 @@ type IPopupHandler interface { // Shows a notification popup with the given title and message to the user. // // This is a convenience wrapper around Confirm(), thus the popup can be closed using both 'Enter' and 'ESC'. - Alert(title string, message string) error + Alert(title string, message string) // Shows a popup asking the user for confirmation. - Confirm(opts ConfirmOpts) error + Confirm(opts ConfirmOpts) // Shows a popup prompting the user for input. - Prompt(opts PromptOpts) error + Prompt(opts PromptOpts) WithWaitingStatus(message string, f func(gocui.Task) error) error WithWaitingStatusSync(message string, f func() error) error Menu(opts CreateMenuOptions) error diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go index cacdb856429..1b7037690f4 100644 --- a/pkg/gui/types/context.go +++ b/pkg/gui/types/context.go @@ -95,18 +95,18 @@ type IBaseContext interface { // We'll need to think of a better way to do this. AddOnClickFn(func() error) - AddOnRenderToMainFn(func() error) - AddOnFocusFn(func(OnFocusOpts) error) - AddOnFocusLostFn(func(OnFocusLostOpts) error) + AddOnRenderToMainFn(func()) + AddOnFocusFn(func(OnFocusOpts)) + AddOnFocusLostFn(func(OnFocusLostOpts)) } type Context interface { IBaseContext - HandleFocus(opts OnFocusOpts) error - HandleFocusLost(opts OnFocusLostOpts) error - HandleRender() error - HandleRenderToMain() error + HandleFocus(opts OnFocusOpts) + HandleFocusLost(opts OnFocusLostOpts) + HandleRender() + HandleRenderToMain() } type ISearchHistoryContext interface { @@ -177,11 +177,11 @@ type IPatchExplorerContext interface { GetState() *patch_exploring.State SetState(*patch_exploring.State) GetIncludedLineIndices() []int - RenderAndFocus(isFocused bool) error - Render(isFocused bool) error - Focus() error + RenderAndFocus(isFocused bool) + Render(isFocused bool) + Focus() GetContentToRender(isFocused bool) string - NavigateTo(isFocused bool, selectedLineIdx int) error + NavigateTo(isFocused bool, selectedLineIdx int) GetMutex() *deadlock.Mutex IsPatchExplorerContext() // used for type switch } @@ -232,9 +232,9 @@ type HasKeybindings interface { GetKeybindings(opts KeybindingsOpts) []*Binding GetMouseKeybindings(opts KeybindingsOpts) []*gocui.ViewMouseBinding GetOnClick() func() error - GetOnRenderToMain() func() error - GetOnFocus() func(OnFocusOpts) error - GetOnFocusLost() func(OnFocusLostOpts) error + GetOnRenderToMain() func() + GetOnFocus() func(OnFocusOpts) + GetOnFocusLost() func(OnFocusLostOpts) } type IController interface { @@ -278,10 +278,10 @@ type ListItem interface { } type IContextMgr interface { - Push(context Context, opts ...OnFocusOpts) error - Pop() error - Replace(context Context) error - Activate(context Context, opts OnFocusOpts) error + Push(context Context, opts ...OnFocusOpts) + Pop() + Replace(context Context) + Activate(context Context, opts OnFocusOpts) Current() Context CurrentStatic() Context CurrentSide() Context diff --git a/pkg/gui/view_helpers.go b/pkg/gui/view_helpers.go index 1ae6251e192..6226797ce22 100644 --- a/pkg/gui/view_helpers.go +++ b/pkg/gui/view_helpers.go @@ -11,13 +11,8 @@ import ( ) func (gui *Gui) resetViewOrigin(v *gocui.View) { - if err := v.SetCursor(0, 0); err != nil { - gui.Log.Error(err) - } - - if err := v.SetOrigin(0, 0); err != nil { - gui.Log.Error(err) - } + v.SetCursor(0, 0) + v.SetOrigin(0, 0) } // Returns the number of lines that we should read initially from a cmd task so @@ -77,7 +72,8 @@ func (gui *Gui) onViewTabClick(windowName string, tabIndex int) error { return nil } - return gui.c.Context().Push(context) + gui.c.Context().Push(context) + return nil } func (gui *Gui) handleNextTab() error { @@ -136,14 +132,10 @@ func (gui *Gui) postRefreshUpdate(c types.Context) error { gui.Log.Infof("postRefreshUpdate for %s took %s", c.GetKey(), time.Since(t)) }() - if err := c.HandleRender(); err != nil { - return err - } + c.HandleRender() if gui.currentViewName() == c.GetViewName() { - if err := c.HandleFocus(types.OnFocusOpts{}); err != nil { - return err - } + c.HandleFocus(types.OnFocusOpts{}) } return nil diff --git a/vendor/github.com/jesseduffield/gocui/gui.go b/vendor/github.com/jesseduffield/gocui/gui.go index c239d25a519..644447d02a4 100644 --- a/vendor/github.com/jesseduffield/gocui/gui.go +++ b/vendor/github.com/jesseduffield/gocui/gui.go @@ -325,8 +325,8 @@ func (g *Gui) SetView(name string, x0, y0, x1, y1 int, overlaps byte) (*View, er newViewCursorX, newOriginX := updatedCursorAndOrigin(0, v.InnerWidth(), cursorX) newViewCursorY, newOriginY := updatedCursorAndOrigin(0, v.InnerHeight(), cursorY) - _ = v.SetCursor(newViewCursorX, newViewCursorY) - _ = v.SetOrigin(newOriginX, newOriginY) + v.SetCursor(newViewCursorX, newViewCursorY) + v.SetOrigin(newOriginX, newOriginY) } } @@ -1204,9 +1204,7 @@ func (g *Gui) ForceRedrawViews(views ...*View) error { } for _, v := range views { - if err := v.draw(); err != nil { - return err - } + v.draw() } Screen.Show() @@ -1252,9 +1250,7 @@ func (g *Gui) draw(v *View) error { Screen.HideCursor() } - if err := v.draw(); err != nil { - return err - } + v.draw() if v.Frame { var fgColor, bgColor, frameColor Attribute @@ -1360,9 +1356,7 @@ func (g *Gui) onKey(ev *GocuiEvent) error { } } if !IsMouseScrollKey(ev.Key) { - if err := v.SetCursor(newCx, newCy); err != nil { - return err - } + v.SetCursor(newCx, newCy) if v.Editable { v.TextArea.SetCursor2D(newX, newY) diff --git a/vendor/github.com/jesseduffield/gocui/view.go b/vendor/github.com/jesseduffield/gocui/view.go index 07dc08f25df..b84405e4a62 100644 --- a/vendor/github.com/jesseduffield/gocui/view.go +++ b/vendor/github.com/jesseduffield/gocui/view.go @@ -14,7 +14,6 @@ import ( "unicode/utf8" "github.com/gdamore/tcell/v2" - "github.com/go-errors/errors" "github.com/mattn/go-runewidth" ) @@ -26,10 +25,6 @@ const ( RIGHT = 8 // view is overlapping at right edge ) -// ErrInvalidPoint is returned when client passed invalid coordinates of a cell. -// Most likely client has passed negative coordinates of a cell. -var ErrInvalidPoint = errors.New("invalid point") - // A View is a window. It maintains its own internal buffer and cursor // position. type View struct { @@ -487,10 +482,10 @@ func (v *View) Name() string { // setRune sets a rune at the given point relative to the view. It applies the // specified colors, taking into account if the cell must be highlighted. Also, // it checks if the position is valid. -func (v *View) setRune(x, y int, ch rune, fgColor, bgColor Attribute) error { +func (v *View) setRune(x, y int, ch rune, fgColor, bgColor Attribute) { maxX, maxY := v.Size() if x < 0 || x >= maxX || y < 0 || y >= maxY { - return ErrInvalidPoint + return } if v.Mask != 0 { @@ -498,27 +493,24 @@ func (v *View) setRune(x, y int, ch rune, fgColor, bgColor Attribute) error { bgColor = v.BgColor ch = v.Mask } else if v.Highlight { - var ( - ry, rcy int - err error - ) - - _, ry, err = v.realPosition(x, y) - if err != nil { - return err + var ry, rcy int + + _, ry, ok := v.realPosition(x, y) + if !ok { + return } - _, rrcy, err := v.realPosition(v.cx, v.cy) - // if error is not nil, then the cursor is out of bounds, which is fine - if err == nil { + _, rrcy, ok := v.realPosition(v.cx, v.cy) + // out of bounds is fine + if ok { rcy = rrcy } rangeSelectStart := rcy rangeSelectEnd := rcy if v.rangeSelectStartY != -1 { - _, realRangeSelectStart, err := v.realPosition(0, v.rangeSelectStartY-v.oy) - if err != nil { - return err + _, realRangeSelectStart, ok := v.realPosition(0, v.rangeSelectStartY-v.oy) + if !ok { + return } rangeSelectStart = min(realRangeSelectStart, rcy) @@ -558,8 +550,6 @@ func (v *View) setRune(x, y int, ch rune, fgColor, bgColor Attribute) error { } tcellSetCell(v.x0+x+1, v.y0+y+1, ch, fgColor, bgColor, v.outMode) - - return nil } func min(a, b int) int { @@ -578,14 +568,13 @@ func max(a, b int) int { // SetCursor sets the cursor position of the view at the given point, // relative to the view. It checks if the position is valid. -func (v *View) SetCursor(x, y int) error { +func (v *View) SetCursor(x, y int) { maxX, maxY := v.Size() if x < 0 || x >= maxX || y < 0 || y >= maxY { - return nil + return } v.cx = x v.cy = y - return nil } func (v *View) SetCursorX(x int) { @@ -622,29 +611,30 @@ func (v *View) CursorY() int { // it is linked with the origin point of view. It can be used to // implement Horizontal and Vertical scrolling with just incrementing // or decrementing ox and oy. -func (v *View) SetOrigin(x, y int) error { - if x < 0 || y < 0 { - return ErrInvalidPoint +func (v *View) SetOrigin(x, y int) { + if x < 0 { + x = 0 } + if y < 0 { + y = 0 + } + v.ox = x v.oy = y - return nil } -func (v *View) SetOriginX(x int) error { +func (v *View) SetOriginX(x int) { if x < 0 { - return ErrInvalidPoint + x = 0 } v.ox = x - return nil } -func (v *View) SetOriginY(y int) error { +func (v *View) SetOriginY(y int) { if y < 0 { - return ErrInvalidPoint + y = 0 } v.oy = y - return nil } // Origin returns the origin position of the view. @@ -662,13 +652,16 @@ func (v *View) OriginY() int { // SetWritePos sets the write position of the view's internal buffer. // So the next Write call would write directly to the specified position. -func (v *View) SetWritePos(x, y int) error { - if x < 0 || y < 0 { - return ErrInvalidPoint +func (v *View) SetWritePos(x, y int) { + if x < 0 { + x = 0 + } + if y < 0 { + y = 0 } + v.wx = x v.wy = y - return nil } // WritePos returns the current write position of the view's internal buffer. @@ -678,14 +671,17 @@ func (v *View) WritePos() (x, y int) { // SetReadPos sets the read position of the view's internal buffer. // So the next Read call would read from the specified position. -func (v *View) SetReadPos(x, y int) error { - if x < 0 || y < 0 { - return ErrInvalidPoint +func (v *View) SetReadPos(x, y int) { + if x < 0 { + x = 0 } + if y < 0 { + y = 0 + } + v.readBuffer = nil v.rx = x v.ry = y - return nil } // ReadPos returns the current read position of the view's internal buffer. @@ -992,16 +988,8 @@ func (v *View) FlushStaleCells() { func (v *View) rewind() { v.ei.reset() - if err := v.SetReadPos(0, 0); err != nil { - // SetReadPos returns error only if x and y are negative - // we are passing 0, 0, thus no error should occur. - panic(err) - } - if err := v.SetWritePos(0, 0); err != nil { - // SetWritePos returns error only if x and y are negative - // we are passing 0, 0, thus no error should occur. - panic(err) - } + v.SetReadPos(0, 0) + v.SetWritePos(0, 0) } func containsUpcaseChar(str string) bool { @@ -1098,12 +1086,12 @@ func (v *View) IsTainted() bool { } // draw re-draws the view's contents. -func (v *View) draw() error { +func (v *View) draw() { v.writeMutex.Lock() defer v.writeMutex.Unlock() if !v.Visible { - return nil + return } v.clearRunes() @@ -1112,7 +1100,7 @@ func (v *View) draw() error { if v.Wrap { if maxX == 0 { - return nil + return } v.ox = 0 } @@ -1125,7 +1113,7 @@ func (v *View) draw() error { } if len(v.viewLines) == 0 { - return nil + return } start := v.oy @@ -1189,9 +1177,7 @@ func (v *View) draw() error { fgColor |= AttrUnderline } - if err := v.setRune(x, y, c.chr, fgColor, bgColor); err != nil { - return err - } + v.setRune(x, y, c.chr, fgColor, bgColor) // Not sure why the previous code was here but it caused problems // when typing wide characters in an editor @@ -1199,7 +1185,6 @@ func (v *View) draw() error { cellIdx++ } } - return nil } func (v *View) refreshViewLinesIfNeeded() { @@ -1268,16 +1253,16 @@ func (v *View) isHoveredHyperlink(x, y int) bool { // realPosition returns the position in the internal buffer corresponding to the // point (x, y) of the view. -func (v *View) realPosition(vx, vy int) (x, y int, err error) { +func (v *View) realPosition(vx, vy int) (x, y int, ok bool) { vx = v.ox + vx vy = v.oy + vy if vx < 0 || vy < 0 { - return 0, 0, ErrInvalidPoint + return 0, 0, false } if len(v.viewLines) == 0 { - return vx, vy, nil + return vx, vy, true } if vy < len(v.viewLines) { @@ -1290,7 +1275,7 @@ func (v *View) realPosition(vx, vy int) (x, y int, err error) { y = vline.linesY + vy - len(v.viewLines) + 1 } - return x, y, nil + return x, y, true } // clearRunes erases all the cells in the view. @@ -1366,29 +1351,29 @@ func (v *View) ViewBuffer() string { // Line returns a string with the line of the view's internal buffer // at the position corresponding to the point (x, y). -func (v *View) Line(y int) (string, error) { - _, y, err := v.realPosition(0, y) - if err != nil { - return "", err +func (v *View) Line(y int) (string, bool) { + _, y, ok := v.realPosition(0, y) + if !ok { + return "", false } if y < 0 || y >= len(v.lines) { - return "", ErrInvalidPoint + return "", false } - return lineType(v.lines[y]).String(), nil + return lineType(v.lines[y]).String(), true } // Word returns a string with the word of the view's internal buffer // at the position corresponding to the point (x, y). -func (v *View) Word(x, y int) (string, error) { - x, y, err := v.realPosition(x, y) - if err != nil { - return "", err +func (v *View) Word(x, y int) (string, bool) { + x, y, ok := v.realPosition(x, y) + if !ok { + return "", false } if x < 0 || y < 0 || y >= len(v.lines) || x >= len(v.lines[y]) { - return "", ErrInvalidPoint + return "", false } str := lineType(v.lines[y]).String() @@ -1405,7 +1390,7 @@ func (v *View) Word(x, y int) (string, error) { } else { nr = nr + x } - return str[nl:nr], nil + return str[nl:nr], true } // indexFunc allows to split lines by words taking into account spaces @@ -1416,10 +1401,9 @@ func indexFunc(r rune) bool { // SetHighlight toggles highlighting of separate lines, for custom lists // or multiple selection in views. -func (v *View) SetHighlight(y int, on bool) error { +func (v *View) SetHighlight(y int, on bool) { if y < 0 || y >= len(v.lines) { - err := ErrInvalidPoint - return err + return } line := v.lines[y] @@ -1437,7 +1421,6 @@ func (v *View) SetHighlight(y int, on bool) error { v.tainted = true v.lines[y] = cells v.clearHover() - return nil } func lineWrap(line []cell, columns int) [][]cell { @@ -1620,8 +1603,8 @@ func (v *View) RenderTextArea() { newViewCursorX, newOriginX := updatedCursorAndOrigin(prevOriginX, width, cursorX) newViewCursorY, newOriginY := updatedCursorAndOrigin(prevOriginY, height, cursorY) - _ = v.SetCursor(newViewCursorX, newViewCursorY) - _ = v.SetOrigin(newOriginX, newOriginY) + v.SetCursor(newViewCursorX, newViewCursorY) + v.SetOrigin(newOriginX, newOriginY) } func updatedCursorAndOrigin(prevOrigin int, size int, cursor int) (int, int) { @@ -1648,8 +1631,8 @@ func (v *View) ClearTextArea() { defer v.writeMutex.Unlock() v.TextArea.Clear() - _ = v.SetOrigin(0, 0) - _ = v.SetCursor(0, 0) + v.SetOrigin(0, 0) + v.SetCursor(0, 0) } func (v *View) overwriteLines(y int, content string) { diff --git a/vendor/golang.org/x/sys/cpu/cpu.go b/vendor/golang.org/x/sys/cpu/cpu.go index ec07aab0578..02609d5b21d 100644 --- a/vendor/golang.org/x/sys/cpu/cpu.go +++ b/vendor/golang.org/x/sys/cpu/cpu.go @@ -201,6 +201,25 @@ var S390X struct { _ CacheLinePad } +// RISCV64 contains the supported CPU features and performance characteristics for riscv64 +// platforms. The booleans in RISCV64, with the exception of HasFastMisaligned, indicate +// the presence of RISC-V extensions. +// +// It is safe to assume that all the RV64G extensions are supported and so they are omitted from +// this structure. As riscv64 Go programs require at least RV64G, the code that populates +// this structure cannot run successfully if some of the RV64G extensions are missing. +// The struct is padded to avoid false sharing. +var RISCV64 struct { + _ CacheLinePad + HasFastMisaligned bool // Fast misaligned accesses + HasC bool // Compressed instruction-set extension + HasV bool // Vector extension compatible with RVV 1.0 + HasZba bool // Address generation instructions extension + HasZbb bool // Basic bit-manipulation extension + HasZbs bool // Single-bit instructions extension + _ CacheLinePad +} + func init() { archInit() initOptions() diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go b/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go index cd63e733557..7d902b6847b 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_noinit.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -//go:build linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x +//go:build linux && !arm && !arm64 && !mips64 && !mips64le && !ppc64 && !ppc64le && !s390x && !riscv64 package cpu diff --git a/vendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go b/vendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go new file mode 100644 index 00000000000..cb4a0c57280 --- /dev/null +++ b/vendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go @@ -0,0 +1,137 @@ +// Copyright 2024 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package cpu + +import ( + "syscall" + "unsafe" +) + +// RISC-V extension discovery code for Linux. The approach here is to first try the riscv_hwprobe +// syscall falling back to HWCAP to check for the C extension if riscv_hwprobe is not available. +// +// A note on detection of the Vector extension using HWCAP. +// +// Support for the Vector extension version 1.0 was added to the Linux kernel in release 6.5. +// Support for the riscv_hwprobe syscall was added in 6.4. It follows that if the riscv_hwprobe +// syscall is not available then neither is the Vector extension (which needs kernel support). +// The riscv_hwprobe syscall should then be all we need to detect the Vector extension. +// However, some RISC-V board manufacturers ship boards with an older kernel on top of which +// they have back-ported various versions of the Vector extension patches but not the riscv_hwprobe +// patches. These kernels advertise support for the Vector extension using HWCAP. Falling +// back to HWCAP to detect the Vector extension, if riscv_hwprobe is not available, or simply not +// bothering with riscv_hwprobe at all and just using HWCAP may then seem like an attractive option. +// +// Unfortunately, simply checking the 'V' bit in AT_HWCAP will not work as this bit is used by +// RISC-V board and cloud instance providers to mean different things. The Lichee Pi 4A board +// and the Scaleway RV1 cloud instances use the 'V' bit to advertise their support for the unratified +// 0.7.1 version of the Vector Specification. The Banana Pi BPI-F3 and the CanMV-K230 board use +// it to advertise support for 1.0 of the Vector extension. Versions 0.7.1 and 1.0 of the Vector +// extension are binary incompatible. HWCAP can then not be used in isolation to populate the +// HasV field as this field indicates that the underlying CPU is compatible with RVV 1.0. +// +// There is a way at runtime to distinguish between versions 0.7.1 and 1.0 of the Vector +// specification by issuing a RVV 1.0 vsetvli instruction and checking the vill bit of the vtype +// register. This check would allow us to safely detect version 1.0 of the Vector extension +// with HWCAP, if riscv_hwprobe were not available. However, the check cannot +// be added until the assembler supports the Vector instructions. +// +// Note the riscv_hwprobe syscall does not suffer from these ambiguities by design as all of the +// extensions it advertises support for are explicitly versioned. It's also worth noting that +// the riscv_hwprobe syscall is the only way to detect multi-letter RISC-V extensions, e.g., Zba. +// These cannot be detected using HWCAP and so riscv_hwprobe must be used to detect the majority +// of RISC-V extensions. +// +// Please see https://docs.kernel.org/arch/riscv/hwprobe.html for more information. + +// golang.org/x/sys/cpu is not allowed to depend on golang.org/x/sys/unix so we must +// reproduce the constants, types and functions needed to make the riscv_hwprobe syscall +// here. + +const ( + // Copied from golang.org/x/sys/unix/ztypes_linux_riscv64.go. + riscv_HWPROBE_KEY_IMA_EXT_0 = 0x4 + riscv_HWPROBE_IMA_C = 0x2 + riscv_HWPROBE_IMA_V = 0x4 + riscv_HWPROBE_EXT_ZBA = 0x8 + riscv_HWPROBE_EXT_ZBB = 0x10 + riscv_HWPROBE_EXT_ZBS = 0x20 + riscv_HWPROBE_KEY_CPUPERF_0 = 0x5 + riscv_HWPROBE_MISALIGNED_FAST = 0x3 + riscv_HWPROBE_MISALIGNED_MASK = 0x7 +) + +const ( + // sys_RISCV_HWPROBE is copied from golang.org/x/sys/unix/zsysnum_linux_riscv64.go. + sys_RISCV_HWPROBE = 258 +) + +// riscvHWProbePairs is copied from golang.org/x/sys/unix/ztypes_linux_riscv64.go. +type riscvHWProbePairs struct { + key int64 + value uint64 +} + +const ( + // CPU features + hwcap_RISCV_ISA_C = 1 << ('C' - 'A') +) + +func doinit() { + // A slice of key/value pair structures is passed to the RISCVHWProbe syscall. The key + // field should be initialised with one of the key constants defined above, e.g., + // RISCV_HWPROBE_KEY_IMA_EXT_0. The syscall will set the value field to the appropriate value. + // If the kernel does not recognise a key it will set the key field to -1 and the value field to 0. + + pairs := []riscvHWProbePairs{ + {riscv_HWPROBE_KEY_IMA_EXT_0, 0}, + {riscv_HWPROBE_KEY_CPUPERF_0, 0}, + } + + // This call only indicates that extensions are supported if they are implemented on all cores. + if riscvHWProbe(pairs, 0) { + if pairs[0].key != -1 { + v := uint(pairs[0].value) + RISCV64.HasC = isSet(v, riscv_HWPROBE_IMA_C) + RISCV64.HasV = isSet(v, riscv_HWPROBE_IMA_V) + RISCV64.HasZba = isSet(v, riscv_HWPROBE_EXT_ZBA) + RISCV64.HasZbb = isSet(v, riscv_HWPROBE_EXT_ZBB) + RISCV64.HasZbs = isSet(v, riscv_HWPROBE_EXT_ZBS) + } + if pairs[1].key != -1 { + v := pairs[1].value & riscv_HWPROBE_MISALIGNED_MASK + RISCV64.HasFastMisaligned = v == riscv_HWPROBE_MISALIGNED_FAST + } + } + + // Let's double check with HWCAP if the C extension does not appear to be supported. + // This may happen if we're running on a kernel older than 6.4. + + if !RISCV64.HasC { + RISCV64.HasC = isSet(hwCap, hwcap_RISCV_ISA_C) + } +} + +func isSet(hwc uint, value uint) bool { + return hwc&value != 0 +} + +// riscvHWProbe is a simplified version of the generated wrapper function found in +// golang.org/x/sys/unix/zsyscall_linux_riscv64.go. We simplify it by removing the +// cpuCount and cpus parameters which we do not need. We always want to pass 0 for +// these parameters here so the kernel only reports the extensions that are present +// on all cores. +func riscvHWProbe(pairs []riscvHWProbePairs, flags uint) bool { + var _zero uintptr + var p0 unsafe.Pointer + if len(pairs) > 0 { + p0 = unsafe.Pointer(&pairs[0]) + } else { + p0 = unsafe.Pointer(&_zero) + } + + _, _, e1 := syscall.Syscall6(sys_RISCV_HWPROBE, uintptr(p0), uintptr(len(pairs)), uintptr(0), uintptr(0), uintptr(flags), 0) + return e1 == 0 +} diff --git a/vendor/golang.org/x/sys/cpu/cpu_riscv64.go b/vendor/golang.org/x/sys/cpu/cpu_riscv64.go index 7f0c79c004b..aca3199c911 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_riscv64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_riscv64.go @@ -8,4 +8,13 @@ package cpu const cacheLineSize = 64 -func initOptions() {} +func initOptions() { + options = []option{ + {Name: "fastmisaligned", Feature: &RISCV64.HasFastMisaligned}, + {Name: "c", Feature: &RISCV64.HasC}, + {Name: "v", Feature: &RISCV64.HasV}, + {Name: "zba", Feature: &RISCV64.HasZba}, + {Name: "zbb", Feature: &RISCV64.HasZbb}, + {Name: "zbs", Feature: &RISCV64.HasZbs}, + } +} diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index d07dd09eb50..e14b766a32c 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -552,6 +552,7 @@ ccflags="$@" $2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ && $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ || $2 ~ /^SOCK_|SK_DIAG_|SKNLGRP_$/ || + $2 ~ /^(CONNECT|SAE)_/ || $2 ~ /^FIORDCHK$/ || $2 ~ /^SIOC/ || $2 ~ /^TIOC/ || diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index 2d15200adb4..099867deede 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -566,6 +566,43 @@ func PthreadFchdir(fd int) (err error) { return pthread_fchdir_np(fd) } +// Connectx calls connectx(2) to initiate a connection on a socket. +// +// srcIf, srcAddr, and dstAddr are filled into a [SaEndpoints] struct and passed as the endpoints argument. +// +// - srcIf is the optional source interface index. 0 means unspecified. +// - srcAddr is the optional source address. nil means unspecified. +// - dstAddr is the destination address. +// +// On success, Connectx returns the number of bytes enqueued for transmission. +func Connectx(fd int, srcIf uint32, srcAddr, dstAddr Sockaddr, associd SaeAssocID, flags uint32, iov []Iovec, connid *SaeConnID) (n uintptr, err error) { + endpoints := SaEndpoints{ + Srcif: srcIf, + } + + if srcAddr != nil { + addrp, addrlen, err := srcAddr.sockaddr() + if err != nil { + return 0, err + } + endpoints.Srcaddr = (*RawSockaddr)(addrp) + endpoints.Srcaddrlen = uint32(addrlen) + } + + if dstAddr != nil { + addrp, addrlen, err := dstAddr.sockaddr() + if err != nil { + return 0, err + } + endpoints.Dstaddr = (*RawSockaddr)(addrp) + endpoints.Dstaddrlen = uint32(addrlen) + } + + err = connectx(fd, &endpoints, associd, flags, iov, &n, connid) + return +} + +//sys connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error) //sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) //sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_hurd.go b/vendor/golang.org/x/sys/unix/syscall_hurd.go index ba46651f8e3..a6a2d2fc2b9 100644 --- a/vendor/golang.org/x/sys/unix/syscall_hurd.go +++ b/vendor/golang.org/x/sys/unix/syscall_hurd.go @@ -11,6 +11,7 @@ package unix int ioctl(int, unsigned long int, uintptr_t); */ import "C" +import "unsafe" func ioctl(fd int, req uint, arg uintptr) (err error) { r0, er := C.ioctl(C.int(fd), C.ulong(req), C.uintptr_t(arg)) diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go index 4308ac1772b..d73c4652e6c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go @@ -237,6 +237,9 @@ const ( CLOCK_UPTIME_RAW_APPROX = 0x9 CLONE_NOFOLLOW = 0x1 CLONE_NOOWNERCOPY = 0x2 + CONNECT_DATA_AUTHENTICATED = 0x4 + CONNECT_DATA_IDEMPOTENT = 0x2 + CONNECT_RESUME_ON_READ_WRITE = 0x1 CR0 = 0x0 CR1 = 0x1000 CR2 = 0x2000 @@ -1265,6 +1268,10 @@ const ( RTV_SSTHRESH = 0x20 RUSAGE_CHILDREN = -0x1 RUSAGE_SELF = 0x0 + SAE_ASSOCID_ALL = 0xffffffff + SAE_ASSOCID_ANY = 0x0 + SAE_CONNID_ALL = 0xffffffff + SAE_CONNID_ANY = 0x0 SCM_CREDS = 0x3 SCM_RIGHTS = 0x1 SCM_TIMESTAMP = 0x2 diff --git a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go index c8068a7a169..4a55a400588 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go @@ -237,6 +237,9 @@ const ( CLOCK_UPTIME_RAW_APPROX = 0x9 CLONE_NOFOLLOW = 0x1 CLONE_NOOWNERCOPY = 0x2 + CONNECT_DATA_AUTHENTICATED = 0x4 + CONNECT_DATA_IDEMPOTENT = 0x2 + CONNECT_RESUME_ON_READ_WRITE = 0x1 CR0 = 0x0 CR1 = 0x1000 CR2 = 0x2000 @@ -1265,6 +1268,10 @@ const ( RTV_SSTHRESH = 0x20 RUSAGE_CHILDREN = -0x1 RUSAGE_SELF = 0x0 + SAE_ASSOCID_ALL = 0xffffffff + SAE_ASSOCID_ANY = 0x0 + SAE_CONNID_ALL = 0xffffffff + SAE_CONNID_ANY = 0x0 SCM_CREDS = 0x3 SCM_RIGHTS = 0x1 SCM_TIMESTAMP = 0x2 diff --git a/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go index da08b2ab3d9..1ec2b1407b1 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_zos_s390x.go @@ -581,6 +581,8 @@ const ( AT_EMPTY_PATH = 0x1000 AT_REMOVEDIR = 0x200 RENAME_NOREPLACE = 1 << 0 + ST_RDONLY = 1 + ST_NOSUID = 2 ) const ( diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index b622533ef2c..24b346e1a35 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -841,6 +841,26 @@ var libc_pthread_fchdir_np_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error) { + var _p0 unsafe.Pointer + if len(iov) > 0 { + _p0 = unsafe.Pointer(&iov[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall9(libc_connectx_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(endpoints)), uintptr(associd), uintptr(flags), uintptr(_p0), uintptr(len(iov)), uintptr(unsafe.Pointer(n)), uintptr(unsafe.Pointer(connid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_connectx_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_connectx connectx "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) { _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags)) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index cfe6646baf2..ebd213100b3 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -248,6 +248,11 @@ TEXT libc_pthread_fchdir_np_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8 DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB) +TEXT libc_connectx_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_connectx(SB) +GLOBL ·libc_connectx_trampoline_addr(SB), RODATA, $8 +DATA ·libc_connectx_trampoline_addr(SB)/8, $libc_connectx_trampoline<>(SB) + TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sendfile(SB) GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 13f624f69f1..824b9c2d5e0 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -841,6 +841,26 @@ var libc_pthread_fchdir_np_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func connectx(fd int, endpoints *SaEndpoints, associd SaeAssocID, flags uint32, iov []Iovec, n *uintptr, connid *SaeConnID) (err error) { + var _p0 unsafe.Pointer + if len(iov) > 0 { + _p0 = unsafe.Pointer(&iov[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + _, _, e1 := syscall_syscall9(libc_connectx_trampoline_addr, uintptr(fd), uintptr(unsafe.Pointer(endpoints)), uintptr(associd), uintptr(flags), uintptr(_p0), uintptr(len(iov)), uintptr(unsafe.Pointer(n)), uintptr(unsafe.Pointer(connid)), 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_connectx_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_connectx connectx "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) { _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags)) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index fe222b75df0..4f178a22934 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -248,6 +248,11 @@ TEXT libc_pthread_fchdir_np_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8 DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB) +TEXT libc_connectx_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_connectx(SB) +GLOBL ·libc_connectx_trampoline_addr(SB), RODATA, $8 +DATA ·libc_connectx_trampoline_addr(SB)/8, $libc_connectx_trampoline<>(SB) + TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sendfile(SB) GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 091d107f3a5..d003c3d4378 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -306,6 +306,19 @@ type XVSockPgen struct { type _Socklen uint32 +type SaeAssocID uint32 + +type SaeConnID uint32 + +type SaEndpoints struct { + Srcif uint32 + Srcaddr *RawSockaddr + Srcaddrlen uint32 + Dstaddr *RawSockaddr + Dstaddrlen uint32 + _ [4]byte +} + type Xucred struct { Version uint32 Uid uint32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index 28ff4ef74d0..0d45a941aae 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -306,6 +306,19 @@ type XVSockPgen struct { type _Socklen uint32 +type SaeAssocID uint32 + +type SaeConnID uint32 + +type SaEndpoints struct { + Srcif uint32 + Srcaddr *RawSockaddr + Srcaddrlen uint32 + Dstaddr *RawSockaddr + Dstaddrlen uint32 + _ [4]byte +} + type Xucred struct { Version uint32 Uid uint32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go index 6cbd094a3aa..51e13eb055f 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_386.go @@ -625,6 +625,7 @@ const ( POLLRDNORM = 0x40 POLLWRBAND = 0x100 POLLWRNORM = 0x4 + POLLRDHUP = 0x4000 ) type CapRights struct { diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go index 7c03b6ee77f..d002d8ef3cc 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_amd64.go @@ -630,6 +630,7 @@ const ( POLLRDNORM = 0x40 POLLWRBAND = 0x100 POLLWRNORM = 0x4 + POLLRDHUP = 0x4000 ) type CapRights struct { diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go index 422107ee8b1..3f863d898dd 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm.go @@ -616,6 +616,7 @@ const ( POLLRDNORM = 0x40 POLLWRBAND = 0x100 POLLWRNORM = 0x4 + POLLRDHUP = 0x4000 ) type CapRights struct { diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go index 505a12acfd9..61c72931066 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_arm64.go @@ -610,6 +610,7 @@ const ( POLLRDNORM = 0x40 POLLWRBAND = 0x100 POLLWRNORM = 0x4 + POLLRDHUP = 0x4000 ) type CapRights struct { diff --git a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go index cc986c79006..b5d17414f03 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_freebsd_riscv64.go @@ -612,6 +612,7 @@ const ( POLLRDNORM = 0x40 POLLWRBAND = 0x100 POLLWRNORM = 0x4 + POLLRDHUP = 0x4000 ) type CapRights struct { diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 7f1961b907a..9f2550dc312 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -2486,7 +2486,7 @@ type XDPMmapOffsets struct { type XDPUmemReg struct { Addr uint64 Len uint64 - Chunk_size uint32 + Size uint32 Headroom uint32 Flags uint32 Tx_metadata_len uint32 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go index 15adc04142f..ad05b51a603 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go @@ -727,6 +727,37 @@ const ( RISCV_HWPROBE_EXT_ZBA = 0x8 RISCV_HWPROBE_EXT_ZBB = 0x10 RISCV_HWPROBE_EXT_ZBS = 0x20 + RISCV_HWPROBE_EXT_ZICBOZ = 0x40 + RISCV_HWPROBE_EXT_ZBC = 0x80 + RISCV_HWPROBE_EXT_ZBKB = 0x100 + RISCV_HWPROBE_EXT_ZBKC = 0x200 + RISCV_HWPROBE_EXT_ZBKX = 0x400 + RISCV_HWPROBE_EXT_ZKND = 0x800 + RISCV_HWPROBE_EXT_ZKNE = 0x1000 + RISCV_HWPROBE_EXT_ZKNH = 0x2000 + RISCV_HWPROBE_EXT_ZKSED = 0x4000 + RISCV_HWPROBE_EXT_ZKSH = 0x8000 + RISCV_HWPROBE_EXT_ZKT = 0x10000 + RISCV_HWPROBE_EXT_ZVBB = 0x20000 + RISCV_HWPROBE_EXT_ZVBC = 0x40000 + RISCV_HWPROBE_EXT_ZVKB = 0x80000 + RISCV_HWPROBE_EXT_ZVKG = 0x100000 + RISCV_HWPROBE_EXT_ZVKNED = 0x200000 + RISCV_HWPROBE_EXT_ZVKNHA = 0x400000 + RISCV_HWPROBE_EXT_ZVKNHB = 0x800000 + RISCV_HWPROBE_EXT_ZVKSED = 0x1000000 + RISCV_HWPROBE_EXT_ZVKSH = 0x2000000 + RISCV_HWPROBE_EXT_ZVKT = 0x4000000 + RISCV_HWPROBE_EXT_ZFH = 0x8000000 + RISCV_HWPROBE_EXT_ZFHMIN = 0x10000000 + RISCV_HWPROBE_EXT_ZIHINTNTL = 0x20000000 + RISCV_HWPROBE_EXT_ZVFH = 0x40000000 + RISCV_HWPROBE_EXT_ZVFHMIN = 0x80000000 + RISCV_HWPROBE_EXT_ZFA = 0x100000000 + RISCV_HWPROBE_EXT_ZTSO = 0x200000000 + RISCV_HWPROBE_EXT_ZACAS = 0x400000000 + RISCV_HWPROBE_EXT_ZICOND = 0x800000000 + RISCV_HWPROBE_EXT_ZIHINTPAUSE = 0x1000000000 RISCV_HWPROBE_KEY_CPUPERF_0 = 0x5 RISCV_HWPROBE_MISALIGNED_UNKNOWN = 0x0 RISCV_HWPROBE_MISALIGNED_EMULATED = 0x1 @@ -734,4 +765,6 @@ const ( RISCV_HWPROBE_MISALIGNED_FAST = 0x3 RISCV_HWPROBE_MISALIGNED_UNSUPPORTED = 0x4 RISCV_HWPROBE_MISALIGNED_MASK = 0x7 + RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE = 0x6 + RISCV_HWPROBE_WHICH_CPUS = 0x1 ) diff --git a/vendor/golang.org/x/sys/windows/syscall_windows.go b/vendor/golang.org/x/sys/windows/syscall_windows.go index 1fa34fd17c5..5cee9a3143f 100644 --- a/vendor/golang.org/x/sys/windows/syscall_windows.go +++ b/vendor/golang.org/x/sys/windows/syscall_windows.go @@ -313,6 +313,10 @@ func NewCallbackCDecl(fn interface{}) uintptr { //sys SetConsoleMode(console Handle, mode uint32) (err error) = kernel32.SetConsoleMode //sys GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) = kernel32.GetConsoleScreenBufferInfo //sys setConsoleCursorPosition(console Handle, position uint32) (err error) = kernel32.SetConsoleCursorPosition +//sys GetConsoleCP() (cp uint32, err error) = kernel32.GetConsoleCP +//sys GetConsoleOutputCP() (cp uint32, err error) = kernel32.GetConsoleOutputCP +//sys SetConsoleCP(cp uint32) (err error) = kernel32.SetConsoleCP +//sys SetConsoleOutputCP(cp uint32) (err error) = kernel32.SetConsoleOutputCP //sys WriteConsole(console Handle, buf *uint16, towrite uint32, written *uint32, reserved *byte) (err error) = kernel32.WriteConsoleW //sys ReadConsole(console Handle, buf *uint16, toread uint32, read *uint32, inputControl *byte) (err error) = kernel32.ReadConsoleW //sys resizePseudoConsole(pconsole Handle, size uint32) (hr error) = kernel32.ResizePseudoConsole diff --git a/vendor/golang.org/x/sys/windows/types_windows.go b/vendor/golang.org/x/sys/windows/types_windows.go index 3f03b3d57cc..7b97a154c95 100644 --- a/vendor/golang.org/x/sys/windows/types_windows.go +++ b/vendor/golang.org/x/sys/windows/types_windows.go @@ -1060,6 +1060,7 @@ const ( SIO_GET_EXTENSION_FUNCTION_POINTER = IOC_INOUT | IOC_WS2 | 6 SIO_KEEPALIVE_VALS = IOC_IN | IOC_VENDOR | 4 SIO_UDP_CONNRESET = IOC_IN | IOC_VENDOR | 12 + SIO_UDP_NETRESET = IOC_IN | IOC_VENDOR | 15 // cf. http://support.microsoft.com/default.aspx?scid=kb;en-us;257460 diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 9bb979a3e47..4c2e1bdc01e 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -247,7 +247,9 @@ var ( procGetCommandLineW = modkernel32.NewProc("GetCommandLineW") procGetComputerNameExW = modkernel32.NewProc("GetComputerNameExW") procGetComputerNameW = modkernel32.NewProc("GetComputerNameW") + procGetConsoleCP = modkernel32.NewProc("GetConsoleCP") procGetConsoleMode = modkernel32.NewProc("GetConsoleMode") + procGetConsoleOutputCP = modkernel32.NewProc("GetConsoleOutputCP") procGetConsoleScreenBufferInfo = modkernel32.NewProc("GetConsoleScreenBufferInfo") procGetCurrentDirectoryW = modkernel32.NewProc("GetCurrentDirectoryW") procGetCurrentProcessId = modkernel32.NewProc("GetCurrentProcessId") @@ -347,8 +349,10 @@ var ( procSetCommMask = modkernel32.NewProc("SetCommMask") procSetCommState = modkernel32.NewProc("SetCommState") procSetCommTimeouts = modkernel32.NewProc("SetCommTimeouts") + procSetConsoleCP = modkernel32.NewProc("SetConsoleCP") procSetConsoleCursorPosition = modkernel32.NewProc("SetConsoleCursorPosition") procSetConsoleMode = modkernel32.NewProc("SetConsoleMode") + procSetConsoleOutputCP = modkernel32.NewProc("SetConsoleOutputCP") procSetCurrentDirectoryW = modkernel32.NewProc("SetCurrentDirectoryW") procSetDefaultDllDirectories = modkernel32.NewProc("SetDefaultDllDirectories") procSetDllDirectoryW = modkernel32.NewProc("SetDllDirectoryW") @@ -2162,6 +2166,15 @@ func GetComputerName(buf *uint16, n *uint32) (err error) { return } +func GetConsoleCP() (cp uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetConsoleCP.Addr(), 0, 0, 0, 0) + cp = uint32(r0) + if cp == 0 { + err = errnoErr(e1) + } + return +} + func GetConsoleMode(console Handle, mode *uint32) (err error) { r1, _, e1 := syscall.Syscall(procGetConsoleMode.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(mode)), 0) if r1 == 0 { @@ -2170,6 +2183,15 @@ func GetConsoleMode(console Handle, mode *uint32) (err error) { return } +func GetConsoleOutputCP() (cp uint32, err error) { + r0, _, e1 := syscall.Syscall(procGetConsoleOutputCP.Addr(), 0, 0, 0, 0) + cp = uint32(r0) + if cp == 0 { + err = errnoErr(e1) + } + return +} + func GetConsoleScreenBufferInfo(console Handle, info *ConsoleScreenBufferInfo) (err error) { r1, _, e1 := syscall.Syscall(procGetConsoleScreenBufferInfo.Addr(), 2, uintptr(console), uintptr(unsafe.Pointer(info)), 0) if r1 == 0 { @@ -3038,6 +3060,14 @@ func SetCommTimeouts(handle Handle, timeouts *CommTimeouts) (err error) { return } +func SetConsoleCP(cp uint32) (err error) { + r1, _, e1 := syscall.Syscall(procSetConsoleCP.Addr(), 1, uintptr(cp), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func setConsoleCursorPosition(console Handle, position uint32) (err error) { r1, _, e1 := syscall.Syscall(procSetConsoleCursorPosition.Addr(), 2, uintptr(console), uintptr(position), 0) if r1 == 0 { @@ -3054,6 +3084,14 @@ func SetConsoleMode(console Handle, mode uint32) (err error) { return } +func SetConsoleOutputCP(cp uint32) (err error) { + r1, _, e1 := syscall.Syscall(procSetConsoleOutputCP.Addr(), 1, uintptr(cp), 0, 0) + if r1 == 0 { + err = errnoErr(e1) + } + return +} + func SetCurrentDirectory(path *uint16) (err error) { r1, _, e1 := syscall.Syscall(procSetCurrentDirectoryW.Addr(), 1, uintptr(unsafe.Pointer(path)), 0, 0) if r1 == 0 { diff --git a/vendor/golang.org/x/term/term_windows.go b/vendor/golang.org/x/term/term_windows.go index 465f560604e..df6bf948e14 100644 --- a/vendor/golang.org/x/term/term_windows.go +++ b/vendor/golang.org/x/term/term_windows.go @@ -26,6 +26,7 @@ func makeRaw(fd int) (*State, error) { return nil, err } raw := st &^ (windows.ENABLE_ECHO_INPUT | windows.ENABLE_PROCESSED_INPUT | windows.ENABLE_LINE_INPUT | windows.ENABLE_PROCESSED_OUTPUT) + raw |= windows.ENABLE_VIRTUAL_TERMINAL_INPUT if err := windows.SetConsoleMode(windows.Handle(fd), raw); err != nil { return nil, err } diff --git a/vendor/modules.txt b/vendor/modules.txt index e08e23a02c9..0405dfd402f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -172,7 +172,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem github.com/jesseduffield/go-git/v5/utils/merkletrie/index github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame github.com/jesseduffield/go-git/v5/utils/merkletrie/noder -# github.com/jesseduffield/gocui v0.3.1-0.20240824154427-0fc91d5098e4 +# github.com/jesseduffield/gocui v0.3.1-0.20240906064314-bfab49c720d7 ## explicit; go 1.12 github.com/jesseduffield/gocui # github.com/jesseduffield/kill v0.0.0-20220618033138-bfbe04675d10 @@ -316,16 +316,16 @@ golang.org/x/net/proxy # golang.org/x/sync v0.8.0 ## explicit; go 1.18 golang.org/x/sync/errgroup -# golang.org/x/sys v0.24.0 +# golang.org/x/sys v0.25.0 ## explicit; go 1.18 golang.org/x/sys/cpu golang.org/x/sys/plan9 golang.org/x/sys/unix golang.org/x/sys/windows -# golang.org/x/term v0.23.0 +# golang.org/x/term v0.24.0 ## explicit; go 1.18 golang.org/x/term -# golang.org/x/text v0.17.0 +# golang.org/x/text v0.18.0 ## explicit; go 1.18 golang.org/x/text/encoding golang.org/x/text/encoding/internal/identifier