diff options
author | Stefan Haller <stefan@haller-berlin.de> | 2023-12-29 14:27:48 +0100 |
---|---|---|
committer | Stefan Haller <stefan@haller-berlin.de> | 2024-01-19 09:25:07 +0100 |
commit | 2c9b4770bcf2fbea44737a40adf872d0bbb89741 (patch) | |
tree | 50ea6f547be69521e5fbd00235241767c9568c55 /pkg/gui/types | |
parent | 98671802020883be6b3e10268db8542bf6c00324 (diff) |
Keep same branch selected when refreshing branches
This wasn't necessary before, because the only available branch sorting option
was by recency, so the sort order couldn't change except by checking out
branches. Now, you can sort by committer date, so the branch order can change by
fetching; in this case it's important to keep the same branch selected. One
important use case is to rebase the checked-out branch onto master; you select
master, press "f" to fetch it (this can now change its position in the list),
and then press "r" to rebase. To make this work smoothly it's important to keep
master selected after pressing "f".
Diffstat (limited to 'pkg/gui/types')
-rw-r--r-- | pkg/gui/types/refresh.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/pkg/gui/types/refresh.go b/pkg/gui/types/refresh.go index 552bfae04..c20a5f54a 100644 --- a/pkg/gui/types/refresh.go +++ b/pkg/gui/types/refresh.go @@ -36,4 +36,11 @@ type RefreshOptions struct { Then func() Scope []RefreshableView // e.g. []RefreshableView{COMMITS, BRANCHES}. Leave empty to refresh everything Mode RefreshMode // one of SYNC (default), ASYNC, and BLOCK_UI + + // Normally a refresh of the branches tries to keep the same branch selected + // (by name); this is usually important in case the order of branches + // changes. Passing true for KeepBranchSelectionIndex suppresses this and + // keeps the selection index the same. Useful after checking out a detached + // head, and selecting index 0. + KeepBranchSelectionIndex bool } |