From 8edcd7123431f7c322d644dd2c09346335f6ca4a Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 4 Sep 2024 13:57:01 +0200 Subject: [PATCH] Remove return value of IPatchExplorerContext.Render, RenderAndFocus, and NavigateTo --- pkg/gui/context/merge_conflicts_context.go | 4 +--- pkg/gui/context/patch_explorer_context.go | 15 ++++++--------- pkg/gui/controllers/merge_conflicts_controller.go | 3 ++- pkg/gui/controllers/patch_explorer_controller.go | 3 ++- pkg/gui/controllers/staging_controller.go | 4 ++-- pkg/gui/types/context.go | 6 +++--- 6 files changed, 16 insertions(+), 19 deletions(-) diff --git a/pkg/gui/context/merge_conflicts_context.go b/pkg/gui/context/merge_conflicts_context.go index 20068bc87..b265fa88e 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 { diff --git a/pkg/gui/context/patch_explorer_context.go b/pkg/gui/context/patch_explorer_context.go index 16b7802e2..c570c323c 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,21 +79,17 @@ 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 { @@ -132,11 +129,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/controllers/merge_conflicts_controller.go b/pkg/gui/controllers/merge_conflicts_controller.go index f851d8b82..66e0153ff 100644 --- a/pkg/gui/controllers/merge_conflicts_controller.go +++ b/pkg/gui/controllers/merge_conflicts_controller.go @@ -329,7 +329,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_explorer_controller.go b/pkg/gui/controllers/patch_explorer_controller.go index 999dc15e9..f6140b62a 100644 --- a/pkg/gui/controllers/patch_explorer_controller.go +++ b/pkg/gui/controllers/patch_explorer_controller.go @@ -300,7 +300,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/staging_controller.go b/pkg/gui/controllers/staging_controller.go index 714b0a760..b2e5667a3 100644 --- a/pkg/gui/controllers/staging_controller.go +++ b/pkg/gui/controllers/staging_controller.go @@ -133,8 +133,8 @@ func (self *StagingController) GetOnFocusLost() func(types.OnFocusLostOpts) erro 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 } diff --git a/pkg/gui/types/context.go b/pkg/gui/types/context.go index 541a4b1d3..f923fa6b9 100644 --- a/pkg/gui/types/context.go +++ b/pkg/gui/types/context.go @@ -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 + RenderAndFocus(isFocused bool) + Render(isFocused bool) Focus() error GetContentToRender(isFocused bool) string - NavigateTo(isFocused bool, selectedLineIdx int) error + NavigateTo(isFocused bool, selectedLineIdx int) GetMutex() *deadlock.Mutex IsPatchExplorerContext() // used for type switch }