mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-21 12:16:54 +02:00
Cleanup: remove unnecessary viewFiles indirection
viewFiles is only called from enter; it doesn't make much sense to fill in a SwitchToCommitFilesContextOpts struct to pass it to viewFiles for this one call. Simply inline viewFiles into enter and get rid of all that.
This commit is contained in:
parent
770d51634c
commit
6ad4ffea3b
@ -60,24 +60,16 @@ func (self *SwitchToDiffFilesController) GetOnClick() func() error {
|
||||
}
|
||||
|
||||
func (self *SwitchToDiffFilesController) enter(ref types.Ref) error {
|
||||
return self.viewFiles(SwitchToCommitFilesContextOpts{
|
||||
Ref: ref,
|
||||
CanRebase: self.context.CanRebase(),
|
||||
Context: self.context,
|
||||
})
|
||||
}
|
||||
|
||||
func (self *SwitchToDiffFilesController) viewFiles(opts SwitchToCommitFilesContextOpts) error {
|
||||
commitFilesContext := self.c.Contexts().CommitFiles
|
||||
|
||||
commitFilesContext.SetSelection(0)
|
||||
commitFilesContext.SetRef(opts.Ref)
|
||||
commitFilesContext.SetTitleRef(opts.Ref.Description())
|
||||
commitFilesContext.SetCanRebase(opts.CanRebase)
|
||||
commitFilesContext.SetParentContext(opts.Context)
|
||||
commitFilesContext.SetWindowName(opts.Context.GetWindowName())
|
||||
commitFilesContext.SetRef(ref)
|
||||
commitFilesContext.SetTitleRef(ref.Description())
|
||||
commitFilesContext.SetCanRebase(self.context.CanRebase())
|
||||
commitFilesContext.SetParentContext(self.context)
|
||||
commitFilesContext.SetWindowName(self.context.GetWindowName())
|
||||
commitFilesContext.ClearSearchString()
|
||||
commitFilesContext.GetView().TitlePrefix = opts.Context.GetView().TitlePrefix
|
||||
commitFilesContext.GetView().TitlePrefix = self.context.GetView().TitlePrefix
|
||||
|
||||
if err := self.c.Refresh(types.RefreshOptions{
|
||||
Scope: []types.RefreshableView{types.COMMIT_FILES},
|
||||
|
@ -1,18 +0,0 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/jesseduffield/lazygit/pkg/gui/types"
|
||||
)
|
||||
|
||||
// all fields mandatory (except `CanRebase` because it's boolean)
|
||||
type SwitchToCommitFilesContextOpts struct {
|
||||
// this is something like a commit or branch
|
||||
Ref types.Ref
|
||||
|
||||
// from the local commits view we're allowed to do rebase stuff with any patch
|
||||
// we generate from the diff files context, but we don't have that same ability
|
||||
// with say the sub commits context or the reflog context.
|
||||
CanRebase bool
|
||||
|
||||
Context types.Context
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user