mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 12:55:47 +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
2 changed files with 6 additions and 32 deletions
|
@ -60,24 +60,16 @@ func (self *SwitchToDiffFilesController) GetOnClick() func() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *SwitchToDiffFilesController) enter(ref types.Ref) 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 := self.c.Contexts().CommitFiles
|
||||||
|
|
||||||
commitFilesContext.SetSelection(0)
|
commitFilesContext.SetSelection(0)
|
||||||
commitFilesContext.SetRef(opts.Ref)
|
commitFilesContext.SetRef(ref)
|
||||||
commitFilesContext.SetTitleRef(opts.Ref.Description())
|
commitFilesContext.SetTitleRef(ref.Description())
|
||||||
commitFilesContext.SetCanRebase(opts.CanRebase)
|
commitFilesContext.SetCanRebase(self.context.CanRebase())
|
||||||
commitFilesContext.SetParentContext(opts.Context)
|
commitFilesContext.SetParentContext(self.context)
|
||||||
commitFilesContext.SetWindowName(opts.Context.GetWindowName())
|
commitFilesContext.SetWindowName(self.context.GetWindowName())
|
||||||
commitFilesContext.ClearSearchString()
|
commitFilesContext.ClearSearchString()
|
||||||
commitFilesContext.GetView().TitlePrefix = opts.Context.GetView().TitlePrefix
|
commitFilesContext.GetView().TitlePrefix = self.context.GetView().TitlePrefix
|
||||||
|
|
||||||
if err := self.c.Refresh(types.RefreshOptions{
|
if err := self.c.Refresh(types.RefreshOptions{
|
||||||
Scope: []types.RefreshableView{types.COMMIT_FILES},
|
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…
Add table
Add a link
Reference in a new issue