jesseduffield.lazygit/pkg/gui/controllers
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
..
helpers Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
attach.go Begin refactoring gui 2023-04-30 13:19:52 +10:00
base_controller.go Begin refactoring gui 2023-04-30 13:19:52 +10:00
basic_commits_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
bisect_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
branches_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
command_log_controller.go lots of changes 2023-04-30 13:19:53 +10:00
commit_description_controller.go Split commit message panel into commit summary and commit description panel 2023-04-30 13:19:53 +10:00
commit_message_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
commits_files_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
common.go lots of changes 2023-04-30 13:19:53 +10:00
confirmation_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
context_lines_controller.go lots of changes 2023-04-30 13:19:53 +10:00
custom_command_action.go move custom command action into its own file 2023-04-30 13:19:53 +10:00
custom_patch_options_menu_action.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
diffing_menu_action.go fix: typo EnteRefName 2023-06-28 18:54:21 +06:00
files_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
files_remove_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
filter_controller.go Introduce filtered list view model 2023-07-03 12:54:13 +10:00
filtering_menu_action.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
git_flow_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
global_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
jump_to_side_window_controller.go move side window actions to controllers package 2023-04-30 13:19:53 +10:00
list_controller.go Introduce filtered list view model 2023-07-03 12:54:13 +10:00
local_commits_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
menu_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
merge_conflicts_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
options_menu_action.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
patch_building_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
patch_explorer_controller.go Introduce filtered list view model 2023-07-03 12:54:13 +10:00
quit_actions.go Cancel filter/search when hitting escape 2023-07-03 12:54:13 +10:00
reflog_commits_controller.go lots of changes 2023-04-30 13:19:53 +10:00
remote_branches_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
remotes_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
screen_mode_actions.go move more actions into controller 2023-04-30 13:19:53 +10:00
search_controller.go Introduce filtered list view model 2023-07-03 12:54:13 +10:00
search_prompt_controller.go Introduce filtered list view model 2023-07-03 12:54:13 +10:00
side_window_controller.go move side window actions to controllers package 2023-04-30 13:19:53 +10:00
snake_controller.go lots of changes 2023-04-30 13:19:53 +10:00
staging_controller.go Rename "Delete change" menu entry to "Discard change" in staging panel 2023-06-26 08:19:58 +02:00
stash_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
status_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00
sub_commits_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
submodules_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
suggestions_controller.go lots of changes 2023-04-30 13:19:53 +10:00
switch_to_diff_files_controller.go Use searching, not filtering, in file tree views 2023-07-03 12:54:14 +10:00
switch_to_sub_commits_controller.go Only cancel search if main or temporary context loses focus 2023-07-03 12:54:14 +10:00
sync_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
tags_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
toggle_whitespace_action.go Remove the toast when toggling "ignore whitespace" 2023-05-20 12:58:32 +10:00
types.go introduce Ref interface 2022-04-02 17:04:42 +11:00
undo_controller.go Use first class task objects instead of global counter 2023-07-09 21:30:19 +10:00
vertical_scroll_controller.go lots of changes 2023-04-30 13:19:53 +10:00
workspace_reset_controller.go Use sentence case everywhere 2023-05-25 23:52:19 +10:00