1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-09-16 09:16:26 +02:00

Remove return value of RenderToMainViews and some related functions

This commit is contained in:
Stefan Haller
2024-09-04 13:42:03 +02:00
parent b91beb68e1
commit 5446683881
29 changed files with 109 additions and 113 deletions

View File

@@ -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 {

View File

@@ -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,

View File

@@ -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
}

View File

@@ -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{})
})
}

View File

@@ -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),