From c87661dbeeea56a74a641d21c6b81614ea640193 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Wed, 2 Jul 2025 12:14:57 +0200 Subject: [PATCH] Use async refresh rather than manual OnWorker call This is exactly what async refresh is for. --- pkg/gui/controllers/local_commits_controller.go | 5 +---- pkg/gui/controllers/sub_commits_controller.go | 6 +----- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pkg/gui/controllers/local_commits_controller.go b/pkg/gui/controllers/local_commits_controller.go index 5bf29c2cd..4a1209642 100644 --- a/pkg/gui/controllers/local_commits_controller.go +++ b/pkg/gui/controllers/local_commits_controller.go @@ -1265,10 +1265,7 @@ func (self *LocalCommitsController) GetOnFocus() func(types.OnFocusOpts) { context := self.context() if context.GetSelectedLineIdx() > COMMIT_THRESHOLD && context.GetLimitCommits() { context.SetLimitCommits(false) - self.c.OnWorker(func(_ gocui.Task) error { - self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}}) - return nil - }) + self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.COMMITS}}) } } } diff --git a/pkg/gui/controllers/sub_commits_controller.go b/pkg/gui/controllers/sub_commits_controller.go index a47469d70..8799cd3c6 100644 --- a/pkg/gui/controllers/sub_commits_controller.go +++ b/pkg/gui/controllers/sub_commits_controller.go @@ -1,7 +1,6 @@ package controllers import ( - "github.com/jesseduffield/gocui" "github.com/jesseduffield/lazygit/pkg/commands/models" "github.com/jesseduffield/lazygit/pkg/gui/context" "github.com/jesseduffield/lazygit/pkg/gui/types" @@ -67,10 +66,7 @@ func (self *SubCommitsController) GetOnFocus() func(types.OnFocusOpts) { context := self.context() if context.GetSelectedLineIdx() > COMMIT_THRESHOLD && context.GetLimitCommits() { context.SetLimitCommits(false) - self.c.OnWorker(func(_ gocui.Task) error { - self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.SUB_COMMITS}}) - return nil - }) + self.c.Refresh(types.RefreshOptions{Mode: types.ASYNC, Scope: []types.RefreshableView{types.SUB_COMMITS}}) } } }