mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
Block input and batch UI updates when switching repos
On startup we don't want to block input during the initial refresh (it should be possible to press, say, `4` to jump to the commits panel right after startup without a delay), and we also want panels to show their contents as soon as possible; it doesn't matter so much that it's not in sync, we go from empty to populated here. However, when switching repos it can be confusing that some panels that are slow to update still show the old repo's data while others already show the new one's data, so update the UI only when everything is ready, and also block input to prevent accidentally trying to act on the old, stale data.
This commit is contained in:
parent
fc975f32a8
commit
975da9b8a9
|
|
@ -1103,12 +1103,31 @@ func (gui *Gui) runSubprocess(cmdObj *oscommands.CmdObj) error {
|
|||
return err
|
||||
}
|
||||
|
||||
var isFirstRefreshAfterStartup = true
|
||||
|
||||
func (gui *Gui) loadNewRepo() error {
|
||||
if err := gui.updateRecentRepoList(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
gui.c.Refresh(types.RefreshOptions{DontBlockRepoSwitch: true})
|
||||
// On startup we don't want to block input during the initial refresh (it
|
||||
// should be possible to press, say, `4` to jump to the commits panel right
|
||||
// after startup without a delay), and we also want panels to show their
|
||||
// contents as soon as possible; it doesn't matter so much that it's not in
|
||||
// sync, we go from empty to populated here. However, when switching repos
|
||||
// it can be confusing that some panels that are slow to update still show
|
||||
// the old repo's data while others already show the new one's data, so
|
||||
// update the UI only when everything is ready, and also block input to
|
||||
// prevent accidentally trying to act on the old, stale data.
|
||||
options := types.RefreshOptions{DontBlockRepoSwitch: true}
|
||||
refresh := gui.c.Refresh
|
||||
if isFirstRefreshAfterStartup {
|
||||
isFirstRefreshAfterStartup = false
|
||||
} else {
|
||||
options.BatchUIUpdates = true
|
||||
refresh = gui.c.RefreshBlockingInput
|
||||
}
|
||||
refresh(options)
|
||||
|
||||
if err := gui.os.UpdateWindowTitle(); err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Reference in a new issue