mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
Remove return value of RenderToMainViews and some related functions
This commit is contained in:
parent
b91beb68e1
commit
5446683881
29 changed files with 109 additions and 113 deletions
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -43,9 +43,7 @@ func (self *SimpleContext) HandleFocus(opts types.OnFocusOpts) error {
|
|||
}
|
||||
|
||||
if self.onRenderToMainFn != nil {
|
||||
if err := self.onRenderToMainFn(); err != nil {
|
||||
return err
|
||||
}
|
||||
self.onRenderToMainFn()
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -63,10 +61,8 @@ func (self *SimpleContext) HandleFocusLost(opts types.OnFocusLostOpts) error {
|
|||
func (self *SimpleContext) HandleRender() {
|
||||
}
|
||||
|
||||
func (self *SimpleContext) HandleRenderToMain() error {
|
||||
func (self *SimpleContext) HandleRenderToMain() {
|
||||
if self.onRenderToMainFn != nil {
|
||||
return self.onRenderToMainFn()
|
||||
self.onRenderToMainFn()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ func (self *baseController) GetOnClick() func() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (self *baseController) GetOnRenderToMain() func() error {
|
||||
func (self *baseController) GetOnRenderToMain() func() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -100,7 +100,7 @@ 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 +111,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,
|
||||
|
|
|
@ -101,7 +101,7 @@ func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpt
|
|||
|
||||
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),
|
||||
|
@ -112,4 +112,6 @@ func (self *PatchBuildingHelper) RefreshPatchBuildingPanel(opts types.OnFocusOpt
|
|||
Title: self.c.Tr.CustomPatch,
|
||||
},
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ 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{})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -151,9 +151,7 @@ func (self *MergeConflictsController) GetOnFocus() func(types.OnFocusOpts) error
|
|||
return func(types.OnFocusOpts) error {
|
||||
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()
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,8 @@ func (self *StagingController) GetOnFocus() func(types.OnFocusOpts) error {
|
|||
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)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -183,11 +183,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 +196,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 +218,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,
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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,7 +109,7 @@ 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 {
|
||||
|
@ -124,15 +121,11 @@ func (gui *Gui) refreshMainViews(opts types.RefreshMainOpts) error {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ type IBaseContext interface {
|
|||
// We'll need to think of a better way to do this.
|
||||
AddOnClickFn(func() error)
|
||||
|
||||
AddOnRenderToMainFn(func() error)
|
||||
AddOnRenderToMainFn(func())
|
||||
AddOnFocusFn(func(OnFocusOpts) error)
|
||||
AddOnFocusLostFn(func(OnFocusLostOpts) error)
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ type Context interface {
|
|||
HandleFocus(opts OnFocusOpts) error
|
||||
HandleFocusLost(opts OnFocusLostOpts) error
|
||||
HandleRender()
|
||||
HandleRenderToMain() error
|
||||
HandleRenderToMain()
|
||||
}
|
||||
|
||||
type ISearchHistoryContext interface {
|
||||
|
@ -232,7 +232,7 @@ type HasKeybindings interface {
|
|||
GetKeybindings(opts KeybindingsOpts) []*Binding
|
||||
GetMouseKeybindings(opts KeybindingsOpts) []*gocui.ViewMouseBinding
|
||||
GetOnClick() func() error
|
||||
GetOnRenderToMain() func() error
|
||||
GetOnRenderToMain() func()
|
||||
GetOnFocus() func(OnFocusOpts) error
|
||||
GetOnFocusLost() func(OnFocusLostOpts) error
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue