mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 12:25:47 +02:00
Return error from RefreshOptions.Then
This commit is contained in:
parent
bbad3a70ce
commit
653994845e
6 changed files with 20 additions and 14 deletions
|
@ -267,16 +267,17 @@ func (self *BisectController) afterMark(selectCurrent bool, waitToReselect bool)
|
|||
}
|
||||
|
||||
func (self *BisectController) afterBisectMarkRefresh(selectCurrent bool, waitToReselect bool) error {
|
||||
selectFn := func() {
|
||||
selectFn := func() error {
|
||||
if selectCurrent {
|
||||
self.selectCurrentBisectCommit()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
if waitToReselect {
|
||||
return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{}, Then: selectFn})
|
||||
} else {
|
||||
selectFn()
|
||||
_ = selectFn()
|
||||
|
||||
return self.c.Helpers().Bisect.PostBisectCommandRefresh()
|
||||
}
|
||||
|
|
|
@ -120,8 +120,9 @@ func (self *FilteringMenuAction) setFiltering() error {
|
|||
return err
|
||||
}
|
||||
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() {
|
||||
return self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}, Then: func() error {
|
||||
self.c.Contexts().LocalCommits.SetSelection(0)
|
||||
self.c.Contexts().LocalCommits.FocusLine()
|
||||
return nil
|
||||
}})
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ func (self *ModeHelper) ClearFiltering() error {
|
|||
|
||||
return self.c.Refresh(types.RefreshOptions{
|
||||
Scope: []types.RefreshableView{types.COMMITS},
|
||||
Then: func() {
|
||||
Then: func() error {
|
||||
// Find the commit that was last selected in filtering mode, and select it again after refreshing
|
||||
if !self.c.Contexts().LocalCommits.SelectCommitByHash(selectedCommitHash) {
|
||||
// If we couldn't find it (either because no commit was selected
|
||||
|
@ -180,6 +180,7 @@ func (self *ModeHelper) ClearFiltering() error {
|
|||
// before we entered filtering
|
||||
self.c.Contexts().LocalCommits.SelectCommitByHash(self.c.Modes().Filtering.GetSelectedCommitHash())
|
||||
}
|
||||
return nil
|
||||
},
|
||||
})
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ func (self *RefreshHelper) Refresh(options types.RefreshOptions) error {
|
|||
)
|
||||
}
|
||||
|
||||
f := func() {
|
||||
f := func() error {
|
||||
var scopeSet *set.Set[types.RefreshableView]
|
||||
if len(options.Scope) == 0 {
|
||||
// not refreshing staging/patch-building unless explicitly requested because we only need
|
||||
|
@ -188,20 +188,22 @@ func (self *RefreshHelper) Refresh(options types.RefreshOptions) error {
|
|||
wg.Wait()
|
||||
|
||||
if options.Then != nil {
|
||||
options.Then()
|
||||
if err := options.Then(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
if options.Mode == types.BLOCK_UI {
|
||||
self.c.OnUIThread(func() error {
|
||||
f()
|
||||
return nil
|
||||
return f()
|
||||
})
|
||||
} else {
|
||||
f()
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
return f()
|
||||
}
|
||||
|
||||
func getScopeNames(scopes []types.RefreshableView) []string {
|
||||
|
|
|
@ -513,7 +513,7 @@ func (self *LocalCommitsController) startInteractiveRebaseWithEdit(
|
|||
err := self.c.Git().Rebase.EditRebase(commitsToEdit[len(commitsToEdit)-1].Hash)
|
||||
return self.c.Helpers().MergeAndRebase.CheckMergeOrRebaseWithRefreshOptions(
|
||||
err,
|
||||
types.RefreshOptions{Mode: types.BLOCK_UI, Then: func() {
|
||||
types.RefreshOptions{Mode: types.BLOCK_UI, Then: func() error {
|
||||
todos := make([]*models.Commit, 0, len(commitsToEdit)-1)
|
||||
for _, c := range commitsToEdit[:len(commitsToEdit)-1] {
|
||||
// Merge commits can't be set to "edit", so just skip them
|
||||
|
@ -524,7 +524,7 @@ func (self *LocalCommitsController) startInteractiveRebaseWithEdit(
|
|||
if len(todos) > 0 {
|
||||
err := self.updateTodos(todo.Edit, todos)
|
||||
if err != nil {
|
||||
_ = self.c.Error(err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -540,6 +540,7 @@ func (self *LocalCommitsController) startInteractiveRebaseWithEdit(
|
|||
if ok1 && ok2 {
|
||||
self.context().SetSelectionRangeAndMode(newSelectedIdx, newRangeStartIdx, rangeSelectMode)
|
||||
}
|
||||
return nil
|
||||
}})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ const (
|
|||
)
|
||||
|
||||
type RefreshOptions struct {
|
||||
Then func()
|
||||
Then func() error
|
||||
Scope []RefreshableView // e.g. []RefreshableView{COMMITS, BRANCHES}. Leave empty to refresh everything
|
||||
Mode RefreshMode // one of SYNC (default), ASYNC, and BLOCK_UI
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue