jesseduffield.lazygit/pkg/gui/controllers/helpers
Stefan Haller fce4816a0d Fix branch selection jumping back on background fetch
When refreshing the branches list, we have code to keep the same branch selected
even when the refresh changes the sort order; this code remembers the selected
branch before the refresh, and then tries to select it again afterwards (looking
it up by name) if it is still there.

However, we stored the previously selected branch too early, before even
obtaining the branches list; if the user moved the selection between that point
and the end of the refresh, it would jump back. Fix this by remembering the
previous selection only at the last moment, right before assigning the new
branches slice.

We still have a race condition here between the UI code that manages the
selection as the user presses arrow keys, and the background thread doing the
refresh that reads and restores the selection; however, the race was there
before, and we make it neither better nor worse with this PR. It doesn't seem to
be a problem in practice.
2025-05-29 14:41:59 +02:00
..
amend_helper.go Allow passing refresh scope to WithGpgHandling 2025-03-24 08:41:58 +01:00
app_status_helper.go Extract the inner part of WithWaitingStatus as a synchronous variant of it 2025-01-30 08:49:58 +01:00
bisect_helper.go Remove return value of Alert/Confirm/Prompt 2024-09-06 08:45:48 +02:00
branches_helper.go Fix possible crash with auto-forwarding branches 2025-05-21 08:21:38 +02:00
cherry_pick_helper.go Make Commit.Hash a getter for an unexported hash field 2025-04-29 14:57:15 +02:00
commits_helper.go Rename OnCommitSuccess to ClearPreservedCommitMessage 2025-05-15 18:37:56 +02:00
commits_helper_test.go Remove hard line breaks when rewording commits 2024-03-09 10:00:44 +01:00
confirmation_helper.go Cleanup: get rid of the variadic parameter of ContextMgr.Push 2025-04-08 16:08:25 +02:00
credentials_helper.go Remove return value of Alert/Confirm/Prompt 2024-09-06 08:45:48 +02:00
diff_helper.go Make Commit.Hash a getter for an unexported hash field 2025-04-29 14:57:15 +02:00
files_helper.go Cleanup: remove unused interfaces for helpers 2025-04-08 16:08:25 +02:00
fixup_helper.go Make Commit.Hash a getter for an unexported hash field 2025-04-29 14:57:15 +02:00
fixup_helper_test.go Also return hunks with only added lines from parseDiff 2024-06-01 08:31:18 +02:00
gpg_helper.go Remove ICmdObj interface 2025-05-01 15:21:37 +02:00
helpers.go Add command to find base commit for creating a fixup 2024-01-10 09:11:40 +01:00
host_helper.go Cleanup: remove unused interfaces for helpers 2025-04-08 16:08:25 +02:00
inline_status_helper.go Remove return value of HandleRender 2024-09-06 08:45:48 +02:00
merge_and_rebase_helper.go Remove MergeAndRebaseHelper's dependency on RefsHelper 2025-04-21 18:12:50 +02:00
merge_conflicts_helper.go Cleanup: get rid of the variadic parameter of ContextMgr.Push 2025-04-08 16:08:25 +02:00
mode_helper.go Make WorkingTreeState a struct, and add cherry-picking and reverting states 2025-04-20 15:53:17 +02:00
patch_building_helper.go Make WorkingTreeState a struct, and add cherry-picking and reverting states 2025-04-20 15:53:17 +02:00
record_directory_helper.go split context common from helper common 2023-04-30 13:19:53 +10:00
refresh_helper.go Fix branch selection jumping back on background fetch 2025-05-29 14:41:59 +02:00
refs_helper.go Make Commit.Hash a getter for an unexported hash field 2025-04-29 14:57:15 +02:00
repos_helper.go Remove ErrorMsg 2024-04-18 10:10:30 +02:00
search_helper.go Cleanup: get rid of the variadic parameter of ContextMgr.Push 2025-04-08 16:08:25 +02:00
snake_helper.go Bump gocui and adapt lazygit code 2024-12-01 10:40:08 +01:00
staging_helper.go Cleanup: get rid of the variadic parameter of ContextMgr.Push 2025-04-08 16:08:25 +02:00
sub_commits_helper.go Store Commit.Hash by pointer (kept in a pool of hashes) 2025-04-29 14:57:15 +02:00
suggestions_helper.go Cleanup: remove unused interfaces for helpers 2025-04-08 16:08:25 +02:00
tags_helper.go Remove the call to OnCommitSuccess from tag creation 2025-05-15 18:33:40 +02:00
update_helper.go Remove return value of Alert/Confirm/Prompt 2024-09-06 08:45:48 +02:00
upstream_helper.go Cleanup: remove unused interfaces for helpers 2025-04-08 16:08:25 +02:00
upstream_helper_test.go Standardise on using lo for slice functions 2023-07-30 18:51:23 +10:00
view_helper.go standardise helper args 2023-04-30 13:19:53 +10:00
window_arrangement_helper.go Change side panel width calculation to work for larger numbers 2025-02-24 07:36:47 +11:00
window_arrangement_helper_test.go Update to go 1.24 2025-03-08 14:53:54 -05:00
window_helper.go Replace CurrentContext() with Context().Current() 2024-08-17 11:14:51 +02:00
working_tree_helper.go Clear preserved commit message when entering CommitEditorPanel 2025-05-15 18:37:56 +02:00
worktree_helper.go Cleanup: remove unused interfaces for helpers 2025-04-08 16:08:25 +02:00