From a0154dc5257e6b3f5c6f8bb25836b3aecc671875 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 10 Jul 2023 12:09:32 +1000 Subject: [PATCH] Refactor --- pkg/tasks/tasks.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go index e2aed471e..33c46380f 100644 --- a/pkg/tasks/tasks.go +++ b/pkg/tasks/tasks.go @@ -186,8 +186,8 @@ func (self *ViewBufferManager) NewCmdTask(start func() (*exec.Cmd, io.Reader), p go utils.Safe(func() { isViewStale := true writeToView := func(content []byte) { - _, _ = self.writer.Write(content) isViewStale = true + _, _ = self.writer.Write(content) } refreshViewIfStale := func() { if isViewStale { @@ -299,18 +299,18 @@ type TaskOpts struct { } func (self *ViewBufferManager) NewTask(f func(TaskOpts) error, key string) error { - task := self.newGocuiTask() + gocuiTask := self.newGocuiTask() var completeTaskOnce sync.Once - completeTask := func() { + completeGocuiTask := func() { completeTaskOnce.Do(func() { - task.Done() + gocuiTask.Done() }) } go utils.Safe(func() { - defer completeTask() + defer completeGocuiTask() self.taskIDMutex.Lock() self.newTaskID++ @@ -350,7 +350,7 @@ func (self *ViewBufferManager) NewTask(f func(TaskOpts) error, key string) error self.waitingMutex.Unlock() - if err := f(TaskOpts{Stop: stop, InitialContentLoaded: completeTask}); err != nil { + if err := f(TaskOpts{Stop: stop, InitialContentLoaded: completeGocuiTask}); err != nil { self.Log.Error(err) // might need an onError callback }