1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-17 01:42:45 +02:00

Move worktrees tab to files window

This commit is contained in:
Jesse Duffield
2023-07-17 16:29:55 +10:00
parent 27ade502ee
commit 0604e43813
2 changed files with 28 additions and 26 deletions

View File

@ -34,7 +34,7 @@ func NewWorktreesContext(c *ContextCommon) *WorktreesContext {
ListContextTrait: &ListContextTrait{ ListContextTrait: &ListContextTrait{
Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{ Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{
View: c.Views().Worktrees, View: c.Views().Worktrees,
WindowName: "branches", WindowName: "files",
Key: WORKTREES_CONTEXT_KEY, Key: WORKTREES_CONTEXT_KEY,
Kind: types.SIDE_CONTEXT, Kind: types.SIDE_CONTEXT,
Focusable: true, Focusable: true,

View File

@ -566,7 +566,8 @@ func (gui *Gui) initGocui(headless bool, test integrationTypes.IntegrationTest)
} }
func (gui *Gui) viewTabMap() map[string][]context.TabView { func (gui *Gui) viewTabMap() map[string][]context.TabView {
branchesTabs := []context.TabView{ result := map[string][]context.TabView{
"branches": {
{ {
Tab: gui.c.Tr.LocalBranchesTitle, Tab: gui.c.Tr.LocalBranchesTitle,
ViewName: "localBranches", ViewName: "localBranches",
@ -579,19 +580,7 @@ func (gui *Gui) viewTabMap() map[string][]context.TabView {
Tab: gui.c.Tr.TagsTitle, Tab: gui.c.Tr.TagsTitle,
ViewName: "tags", ViewName: "tags",
}, },
}
if gui.c.Git().Version.SupportsWorktrees() {
branchesTabs = append(branchesTabs,
context.TabView{
Tab: gui.c.Tr.WorktreesTitle,
ViewName: "worktrees",
}, },
)
}
return map[string][]context.TabView{
"branches": branchesTabs,
"commits": { "commits": {
{ {
Tab: gui.c.Tr.CommitsTitle, Tab: gui.c.Tr.CommitsTitle,
@ -613,6 +602,19 @@ func (gui *Gui) viewTabMap() map[string][]context.TabView {
}, },
}, },
} }
if gui.c.Git().Version.SupportsWorktrees() {
// insert between files and submodules tabs
result["files"] = append(result["files"][0:1],
context.TabView{
Tab: gui.c.Tr.WorktreesTitle,
ViewName: "worktrees",
},
result["files"][1],
)
}
return result
} }
// Run: setup the gui with keybindings and start the mainloop // Run: setup the gui with keybindings and start the mainloop