From a1fae4105116775b5c4a0c9c3b01fa822b29cfac Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Sat, 29 Jul 2023 13:31:12 +1000 Subject: [PATCH] Fix bug where worktree view would take over window upon switching branches When switching worktrees (which we can now do via the branch view) we re-layout the windows and their views. We had the worktree view ahead of the file view based on the Flatten() method in context.go, because it used to be associated with the branches panel. --- pkg/gui/context/context.go | 2 +- pkg/integration/tests/worktree/add_from_branch.go | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/gui/context/context.go b/pkg/gui/context/context.go index ecb0e6da4..7008f7d14 100644 --- a/pkg/gui/context/context.go +++ b/pkg/gui/context/context.go @@ -124,10 +124,10 @@ func (self *ContextTree) Flatten() []types.Context { self.Status, self.Snake, self.Submodules, + self.Worktrees, self.Files, self.SubCommits, self.Remotes, - self.Worktrees, self.RemoteBranches, self.Tags, self.Branches, diff --git a/pkg/integration/tests/worktree/add_from_branch.go b/pkg/integration/tests/worktree/add_from_branch.go index 53636536d..70aa4dd60 100644 --- a/pkg/integration/tests/worktree/add_from_branch.go +++ b/pkg/integration/tests/worktree/add_from_branch.go @@ -55,6 +55,11 @@ var AddFromBranch = NewIntegrationTest(NewIntegrationTestArgs{ Lines( Contains("mybranch").IsSelected(), Contains("newbranch (worktree)"), - ) + ). + // Confirm the files view is still showing in the files window + Press(keys.Universal.PrevBlock) + + t.Views().Files(). + IsFocused() }, })