mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-09-10 07:36:27 -04:00
fixup! Truncate the repo and branch names in the recent repos menu
This commit is contained in:
parent
f113736aac
commit
f5df1354fe
|
|
@ -132,6 +132,42 @@ func (self *ReposHelper) recentRepoTooltip(repoName string, branchName string) s
|
|||
}), "\n")
|
||||
}
|
||||
|
||||
func (self *ReposHelper) recentRepoMenuItem(path string, branchName string) *types.MenuItem {
|
||||
repoName := filepath.Base(path)
|
||||
|
||||
displayedBranchName := utils.TruncateWithEllipsis(branchName, recentReposColumnMaxWidth)
|
||||
if icons.IsIconEnabled() {
|
||||
displayedBranchName = icons.BRANCH_ICON + " " + displayedBranchName
|
||||
}
|
||||
|
||||
return &types.MenuItem{
|
||||
LabelColumns: []string{
|
||||
utils.TruncateWithEllipsis(repoName, recentReposColumnMaxWidth),
|
||||
style.FgCyan.Sprint(displayedBranchName),
|
||||
// The last segment of the path is already in the first column, so
|
||||
// showing the directory that contains the repo is enough to tell
|
||||
// repos with the same name apart.
|
||||
style.FgMagenta.Sprint(utils.ContractTilde(filepath.Dir(path))),
|
||||
},
|
||||
// Filtering matches the full text, including the parts that the columns
|
||||
// above truncate or leave out.
|
||||
FilterColumns: []string{repoName, branchName, path},
|
||||
Tooltip: self.recentRepoTooltip(repoName, branchName),
|
||||
OnPress: func() error {
|
||||
// Check before clearing the stack, so a refused switch doesn't
|
||||
// forget the submodule breadcrumb (which would leave escape
|
||||
// unable to return to the parent repo).
|
||||
if self.switchRefusedBecauseBusy() {
|
||||
return nil
|
||||
}
|
||||
// if we were in a submodule, we want to forget about that stack of repos
|
||||
// so that hitting escape in the new repo does nothing
|
||||
self.c.State().GetRepoPathStack().Clear()
|
||||
return self.switchTo(path, self.c.Tr.ErrRepositoryMovedOrDeleted, context.NO_CONTEXT)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *ReposHelper) CreateRecentReposMenu() error {
|
||||
// we'll show an empty panel if there are no recent repos
|
||||
recentRepoPaths := []string{}
|
||||
|
|
@ -155,40 +191,7 @@ func (self *ReposHelper) CreateRecentReposMenu() error {
|
|||
wg.Wait()
|
||||
|
||||
menuItems := lo.Map(recentRepoPaths, func(path string, i int) *types.MenuItem {
|
||||
repoName := filepath.Base(path)
|
||||
branchName := currentBranches[i]
|
||||
|
||||
displayedBranchName := utils.TruncateWithEllipsis(branchName, recentReposColumnMaxWidth)
|
||||
if icons.IsIconEnabled() {
|
||||
displayedBranchName = icons.BRANCH_ICON + " " + displayedBranchName
|
||||
}
|
||||
|
||||
return &types.MenuItem{
|
||||
LabelColumns: []string{
|
||||
utils.TruncateWithEllipsis(repoName, recentReposColumnMaxWidth),
|
||||
style.FgCyan.Sprint(displayedBranchName),
|
||||
// The last segment of the path is already in the first column,
|
||||
// so showing the directory that contains the repo is enough to
|
||||
// tell repos with the same name apart.
|
||||
style.FgMagenta.Sprint(utils.ContractTilde(filepath.Dir(path))),
|
||||
},
|
||||
// Filtering matches the full text, including the parts that the
|
||||
// columns above truncate or leave out.
|
||||
FilterColumns: []string{repoName, branchName, path},
|
||||
Tooltip: self.recentRepoTooltip(repoName, branchName),
|
||||
OnPress: func() error {
|
||||
// Check before clearing the stack, so a refused switch doesn't
|
||||
// forget the submodule breadcrumb (which would leave escape
|
||||
// unable to return to the parent repo).
|
||||
if self.switchRefusedBecauseBusy() {
|
||||
return nil
|
||||
}
|
||||
// if we were in a submodule, we want to forget about that stack of repos
|
||||
// so that hitting escape in the new repo does nothing
|
||||
self.c.State().GetRepoPathStack().Clear()
|
||||
return self.switchTo(path, self.c.Tr.ErrRepositoryMovedOrDeleted, context.NO_CONTEXT)
|
||||
},
|
||||
}
|
||||
return self.recentRepoMenuItem(path, currentBranches[i])
|
||||
})
|
||||
|
||||
return self.c.Menu(types.CreateMenuOptions{
|
||||
|
|
|
|||
Loading…
Reference in a new issue