1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

show namesake for child views

This commit is contained in:
Jesse Duffield
2022-03-26 14:44:30 +11:00
parent 13b90ac37f
commit ad7703df65
32 changed files with 766 additions and 649 deletions

View File

@ -497,9 +497,7 @@ func (self *LocalCommitsController) createFixupCommit(commit *models.Commit) err
func (self *LocalCommitsController) squashAllAboveFixupCommits(commit *models.Commit) error {
prompt := utils.ResolvePlaceholderString(
self.c.Tr.SureSquashAboveCommits,
map[string]string{
"commit": commit.Sha,
},
map[string]string{"commit": commit.Sha},
)
return self.c.Ask(types.AskOpts{
@ -561,7 +559,9 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
}
return self.c.WithWaitingStatus(self.c.Tr.LcLoadingCommits, func() error {
return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.COMMITS}})
return self.c.Refresh(
types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.COMMITS}},
)
})
},
},
@ -602,7 +602,12 @@ func (self *LocalCommitsController) handleOpenLogMenu() error {
return func() error {
self.c.UserConfig.Git.Log.Order = value
return self.c.WithWaitingStatus(self.c.Tr.LcLoadingCommits, func() error {
return self.c.Refresh(types.RefreshOptions{Mode: types.SYNC, Scope: []types.RefreshableView{types.COMMITS}})
return self.c.Refresh(
types.RefreshOptions{
Mode: types.SYNC,
Scope: []types.RefreshableView{types.COMMITS},
},
)
})
}
}

View File

@ -73,6 +73,11 @@ func (self *RemotesController) enter(remote *models.Remote) error {
newSelectedLine = -1
}
self.contexts.RemoteBranches.SetSelectedLineIdx(newSelectedLine)
self.contexts.RemoteBranches.SetTitleRef(remote.Name)
if err := self.c.PostRefreshUpdate(self.contexts.RemoteBranches); err != nil {
return err
}
return self.c.PushContext(self.contexts.RemoteBranches)
}

View File

@ -12,6 +12,7 @@ type CanSwitchToDiffFiles interface {
types.Context
CanRebase() bool
GetSelectedRefName() string
GetSelectedDescription() string
}
type SwitchToDiffFilesController struct {
@ -63,9 +64,10 @@ func (self *SwitchToDiffFilesController) checkSelected(callback func(string) err
func (self *SwitchToDiffFilesController) enter(refName string) error {
return self.viewFiles(SwitchToCommitFilesContextOpts{
RefName: refName,
CanRebase: self.context.CanRebase(),
Context: self.context,
RefName: refName,
RefDescription: self.context.GetSelectedDescription(),
CanRebase: self.context.CanRebase(),
Context: self.context,
})
}

View File

@ -11,6 +11,7 @@ var _ types.IController = &SwitchToSubCommitsController{}
type CanSwitchToSubCommits interface {
types.Context
GetSelectedRefName() string
GetSelectedDescription() string
}
type SwitchToSubCommitsController struct {
@ -74,6 +75,7 @@ func (self *SwitchToSubCommitsController) viewCommits() error {
self.contexts.SubCommits.SetSelectedLineIdx(0)
self.contexts.SubCommits.SetParentContext(self.context)
self.contexts.SubCommits.SetWindowName(self.context.GetWindowName())
self.contexts.SubCommits.SetTitleRef(self.context.GetSelectedDescription())
self.contexts.SubCommits.SetRefName(refName)
err = self.c.PostRefreshUpdate(self.contexts.SubCommits)

View File

@ -6,7 +6,17 @@ import (
// all fields mandatory (except `CanRebase` because it's boolean)
type SwitchToCommitFilesContextOpts struct {
RefName string
// this is something like a commit sha or branch name
RefName string
// this will be displayed in the title of the view so we know whose diff files
// we're viewing
RefDescription string
// 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
Context types.Context
}