1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-31 14:24:25 +03:00

Cleanup: reduce some code duplication

ListContextTrait.OnSearchSelect was introduced in 138be04e65, but it was never
called. I can only guess that a planned refactoring wasn't finished here.
This commit is contained in:
Stefan Haller
2024-06-05 16:55:32 +02:00
parent 3af545daf7
commit 27ad75de16
4 changed files with 4 additions and 16 deletions

View File

@ -64,10 +64,7 @@ func NewCommitFilesContext(c *ContextCommon) *CommitFilesContext {
}, },
} }
ctx.GetView().SetOnSelectItem(ctx.SearchTrait.onSelectItemWrapper(func(selectedLineIdx int) error { ctx.GetView().SetOnSelectItem(ctx.SearchTrait.onSelectItemWrapper(ctx.OnSearchSelect))
ctx.GetList().SetSelection(selectedLineIdx)
return ctx.HandleFocus(types.OnFocusOpts{})
}))
return ctx return ctx
} }

View File

@ -85,10 +85,7 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
}, },
} }
ctx.GetView().SetOnSelectItem(ctx.SearchTrait.onSelectItemWrapper(func(selectedLineIdx int) error { ctx.GetView().SetOnSelectItem(ctx.SearchTrait.onSelectItemWrapper(ctx.OnSearchSelect))
ctx.GetList().SetSelection(selectedLineIdx)
return ctx.HandleFocus(types.OnFocusOpts{})
}))
return ctx return ctx
} }

View File

@ -133,10 +133,7 @@ func NewSubCommitsContext(
}, },
} }
ctx.GetView().SetOnSelectItem(ctx.SearchTrait.onSelectItemWrapper(func(selectedLineIdx int) error { ctx.GetView().SetOnSelectItem(ctx.SearchTrait.onSelectItemWrapper(ctx.OnSearchSelect))
ctx.GetList().SetSelection(selectedLineIdx)
return ctx.HandleFocus(types.OnFocusOpts{})
}))
return ctx return ctx
} }

View File

@ -51,10 +51,7 @@ func NewWorkingTreeContext(c *ContextCommon) *WorkingTreeContext {
}, },
} }
ctx.GetView().SetOnSelectItem(ctx.SearchTrait.onSelectItemWrapper(func(selectedLineIdx int) error { ctx.GetView().SetOnSelectItem(ctx.SearchTrait.onSelectItemWrapper(ctx.OnSearchSelect))
ctx.GetList().SetSelection(selectedLineIdx)
return ctx.HandleFocus(types.OnFocusOpts{})
}))
return ctx return ctx
} }