jesseduffield.lazygit/pkg/commands
Jesse Duffield 23bcc19180 allow fast flicking through any list panel
Up till now our approach to rendering things like file diffs, branch logs, and
commit patches, has been to run a command on the command line, wait for it to
complete, take its output as a string, and then write that string to the main
view (or secondary view e.g. when showing both staged and unstaged changes of a
file).

This has caused various issues. For once, if you are flicking through a list of
files and an untracked file is particularly large, not only will this require
lazygit to load that whole file into memory (or more accurately it's equally
large diff), it also will slow down the UI thread while loading that file, and
if the user continued down the list, the original command might eventually
resolve and replace whatever the diff is for the newly selected file.

Following what we've done in lazydocker, I've added a tasks package for when you
need something done but you want it to cancel as soon as something newer comes
up. Given this typically involves running a command to display to a view, I've
added a viewBufferManagerMap struct to the Gui struct which allows you to define
these tasks on a per-view basis.

viewBufferManagers can run files and directly write the output to their view,
meaning we no longer need to use so much memory.

In the tasks package there is a helper method called NewCmdTask which takes a
command, an initial amount of lines to read, and then runs that command, reads
that number of lines, and allows for a readLines channel to tell it to read more
lines. We read more lines when we scroll or resize the window.

There is an adapter for the tasks package in a file called tasks_adapter which
wraps the functions from the tasks package in gui-specific stuff like clearing
the main view before starting the next task that wants to write to the main
view.

I've removed some small features as part of this work, namely the little headers
that were at the top of the main view for some situations. For example, we no
longer show the upstream of a selected branch. I want to re-introduce this in
the future, but I didn't want to make this tasks system too complicated, and in
order to facilitate a header section in the main view we'd need to have a task
that gets the upstream for the current branch, writes it to the header, then
tells another task to write the branch log to the main view, but without
clearing inbetween. So it would get messy. I'm thinking instead of having a
separate 'header' view atop the main view to render that kind of thing (which
can happen in another PR)

I've also simplified the 'git show' to just call 'git show' and not do anything
fancy when it comes to merge commits.

I considered using this tasks approach whenever we write to a view. The only
thing is that the renderString method currently resets the origin of a view and
I don't want to lose that. So I've left some in there that I consider harmless,
but we should probably be just using tasks now for all rendering, even if it's
just strings we can instantly make.
2020-01-12 11:17:20 +11:00
..
testdata Support opening lazygit in a submodule 2019-05-12 17:59:49 +10:00
branch.go split RemoteBranch out from Branch 2019-11-21 22:07:14 +11:00
branch_list_builder.go don't pass single commands directly to RunCommand (or equivalent function) 2019-11-21 22:07:14 +11:00
commit.go add reflog tab in commits panel 2020-01-09 22:36:07 +11:00
commit_file.go Support building and moving patches 2019-11-05 19:22:01 +11:00
commit_list_builder.go lazyload commits 2020-01-12 10:10:56 +11:00
commit_list_builder_test.go lazyload commits 2020-01-12 10:10:56 +11:00
dummies.go fix up tests 2019-03-02 13:39:09 +11:00
errors.go allow user to discard old file changes for a given commit 2019-03-16 10:20:27 +11:00
exec_live_default.go add GIT_OPTIONAL_LOCKS=0 env var to all commands 2019-06-06 20:53:35 +10:00
exec_live_win.go pkg: Fix typo 2019-01-16 18:06:11 +11:00
file.go #477 Remove NeedMerge boolean 2019-07-27 11:05:23 +10:00
git.go allow fast flicking through any list panel 2020-01-12 11:17:20 +11:00
git_structs.go color merged and unmerged commits differently 2018-09-18 21:45:35 +10:00
git_test.go allow fast flicking through any list panel 2020-01-12 11:17:20 +11:00
loading_remotes.go support older versions of git when getting remote branches 2019-11-26 21:36:07 +11:00
loading_tags.go lenient sorting of tags on startup 2019-11-26 21:39:40 +11:00
os.go escape editor path 2020-01-08 22:24:36 +11:00
os_default_platform.go windows support for skipping the editor 2019-03-03 12:44:10 +11:00
os_test.go fix up tests 2019-03-02 13:39:09 +11:00
os_windows.go refactor: move fallback to platform struct 2018-09-10 10:31:15 +02:00
patch_manager.go reset patch builder when we've escaped from the building phase and nothing has been added 2019-11-10 16:18:25 +11:00
patch_modifier.go Support building and moving patches 2019-11-05 19:22:01 +11:00
patch_modifier_test.go only test with non-original header 2019-11-05 19:22:01 +11:00
patch_parser.go strip whitespace when there is nothing else 2019-11-05 19:22:01 +11:00
patch_rebases.go don't let patch manager ever be nil 2019-11-05 19:22:01 +11:00
pull_request.go Update bitbucket pull request url. 2019-03-16 11:58:26 +11:00
pull_request_test.go Update bitbucket pull request url. 2019-03-16 11:58:26 +11:00
remote.go support adding/removing remotes 2019-11-21 22:07:14 +11:00
remote_branch.go support detached heads when showing the selected branch 2019-11-21 22:07:14 +11:00
stash_entry.go fix typo 2019-07-14 14:24:59 +10:00
tag.go add tags panel 2019-11-21 22:07:14 +11:00