From 0604e43813f9befc9738572deaeaba06fcf2a2e3 Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Mon, 17 Jul 2023 16:29:55 +1000 Subject: [PATCH] Move worktrees tab to files window --- pkg/gui/context/worktrees_context.go | 2 +- pkg/gui/gui.go | 52 +++++++++++++++------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/pkg/gui/context/worktrees_context.go b/pkg/gui/context/worktrees_context.go index aa1dcd4a1..7f15d67b1 100644 --- a/pkg/gui/context/worktrees_context.go +++ b/pkg/gui/context/worktrees_context.go @@ -34,7 +34,7 @@ func NewWorktreesContext(c *ContextCommon) *WorktreesContext { ListContextTrait: &ListContextTrait{ Context: NewSimpleContext(NewBaseContext(NewBaseContextOpts{ View: c.Views().Worktrees, - WindowName: "branches", + WindowName: "files", Key: WORKTREES_CONTEXT_KEY, Kind: types.SIDE_CONTEXT, Focusable: true, diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index 1b58c7a9a..838d70792 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -566,32 +566,21 @@ func (gui *Gui) initGocui(headless bool, test integrationTypes.IntegrationTest) } func (gui *Gui) viewTabMap() map[string][]context.TabView { - branchesTabs := []context.TabView{ - { - Tab: gui.c.Tr.LocalBranchesTitle, - ViewName: "localBranches", - }, - { - Tab: gui.c.Tr.RemotesTitle, - ViewName: "remotes", - }, - { - Tab: gui.c.Tr.TagsTitle, - ViewName: "tags", - }, - } - - if gui.c.Git().Version.SupportsWorktrees() { - branchesTabs = append(branchesTabs, - context.TabView{ - Tab: gui.c.Tr.WorktreesTitle, - ViewName: "worktrees", + result := map[string][]context.TabView{ + "branches": { + { + Tab: gui.c.Tr.LocalBranchesTitle, + ViewName: "localBranches", }, - ) - } - - return map[string][]context.TabView{ - "branches": branchesTabs, + { + Tab: gui.c.Tr.RemotesTitle, + ViewName: "remotes", + }, + { + Tab: gui.c.Tr.TagsTitle, + ViewName: "tags", + }, + }, "commits": { { 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