summaryrefslogtreecommitdiffstats
path: root/pkg/tasks/tasks.go
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-09 21:09:52 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-10 17:12:21 +1000
commit6b9390409eb533fe87648be55e9db7d36b1d9ee3 (patch)
tree43e35b86a17dbee8aac245cc93c2645727b61148 /pkg/tasks/tasks.go
parent8964cedf27cbdb81f59e2400cfc89684d7458605 (diff)
Use an interface for tasks instead of a concrete struct
By using an interface for tasks we can use a fake implementation in tests with extra methods
Diffstat (limited to 'pkg/tasks/tasks.go')
-rw-r--r--pkg/tasks/tasks.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/pkg/tasks/tasks.go b/pkg/tasks/tasks.go
index 498d8a1da..e2aed471e 100644
--- a/pkg/tasks/tasks.go
+++ b/pkg/tasks/tasks.go
@@ -50,7 +50,10 @@ type ViewBufferManager struct {
onEndOfInput func()
// see docs/dev/Busy.md
- newTask func() *gocui.Task
+ // A gocui task is not the same thing as the tasks defined in this file.
+ // A gocui task simply represents the fact that lazygit is busy doing something,
+ // whereas the tasks in this file are about rendering content to a view.
+ newGocuiTask func() gocui.Task
// if the user flicks through a heap of items, with each one
// spawning a process to render something to the main view,
@@ -80,7 +83,7 @@ func NewViewBufferManager(
refreshView func(),
onEndOfInput func(),
onNewKey func(),
- newTask func() *gocui.Task,
+ newGocuiTask func() gocui.Task,
) *ViewBufferManager {
return &ViewBufferManager{
Log: log,
@@ -90,7 +93,7 @@ func NewViewBufferManager(
onEndOfInput: onEndOfInput,
readLines: make(chan LinesToRead, 1024),
onNewKey: onNewKey,
- newTask: newTask,
+ newGocuiTask: newGocuiTask,
}
}
@@ -296,7 +299,7 @@ type TaskOpts struct {
}
func (self *ViewBufferManager) NewTask(f func(TaskOpts) error, key string) error {
- task := self.newTask()
+ task := self.newGocuiTask()
var completeTaskOnce sync.Once