jesseduffield.lazygit/pkg
Jesse Duffield 14ecc15e71 Use first class task objects instead of global counter
The global counter approach is easy to understand but it's brittle and depends on implicit behaviour that is not very discoverable.

With a global counter, if any goroutine accidentally decrements the counter twice, we'll think lazygit is idle when it's actually busy.
Likewise if a goroutine accidentally increments the counter twice we'll think lazygit is busy when it's actually idle.
With the new approach we have a map of tasks where each task can either be busy or not. We create a new task and add it to the map
when we spawn a worker goroutine (among other things) and we remove it once the task is done.

The task can also be paused and continued for situations where we switch back and forth between running a program and asking for user
input.

In order for this to work with `git push` (and other commands that require credentials) we need to obtain the task from gocui when
we create the worker goroutine, and then pass it along to the commands package to pause/continue the task as required. This is
MUCH more discoverable than the old approach which just decremented and incremented the global counter from within the commands package,
but it's at the cost of expanding some function signatures (arguably a good thing).

Likewise, whenever you want to call WithWaitingStatus or WithLoaderPanel the callback will now have access to the task for pausing/
continuing. We only need to actually make use of this functionality in a couple of places so it's a high price to pay, but I don't
know if I want to introduce a WithWaitingStatusTask and WithLoaderPanelTask function (open to suggestions).
2023-07-09 21:30:19 +10:00
..
app Use comment char config on interactive rebase 2023-07-02 02:07:32 -03:00
cheatsheet Use sentence case everywhere 2023-05-25 23:52:19 +10:00
commands Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
common introduce Common struct for passing around common stuff 2022-01-04 09:07:15 +11:00
config Color view frame differently when searching/filtering 2023-07-03 12:54:14 +10:00
constants update release notes 2021-04-20 18:34:47 +10:00
env clearer separation of concerns when bootstrapping application 2022-05-07 16:02:04 +10:00
fakes cleanup integration test code 2023-02-26 12:54:13 +11:00
gui Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
i18n Differentiate between different filter modes 2023-07-03 12:54:14 +10:00
integration Fix test 2023-07-09 20:57:18 +10:00
logs Allow global logging when developing 2023-05-25 18:31:32 +10:00
secureexec Cache binary paths 2023-05-23 19:15:33 +10:00
snake integrate snake game into lazygit 2022-12-30 12:18:59 +11:00
tasks Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
theme Color view frame differently when searching/filtering 2023-07-03 12:54:14 +10:00
updates Construct arg vector manually rather than parse string 2023-05-23 19:49:19 +10:00
utils View filtering (#2680) 2023-07-03 12:57:11 +10:00