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

Prompt to switch to worktree when branch is checked out by other worktree

This commit is contained in:
Jesse Duffield
2023-07-16 14:14:09 +10:00
parent fe8adf9eb8
commit 077ae99438
5 changed files with 53 additions and 17 deletions

View File

@ -34,7 +34,7 @@ func (self *WorktreesController) GetKeybindings(opts types.KeybindingsOpts) []*t
{
Key: opts.GetKey(opts.Config.Universal.Select),
Handler: self.checkSelected(self.enter),
Description: self.c.Tr.EnterWorktree,
Description: self.c.Tr.SwitchToWorktree,
},
{
Key: opts.GetKey(opts.Config.Universal.Remove),
@ -143,15 +143,7 @@ func (self *WorktreesController) GetOnClick() func() error {
}
func (self *WorktreesController) enter(worktree *models.Worktree) error {
if self.c.Git().Worktree.IsCurrentWorktree(worktree) {
return self.c.ErrorMsg(self.c.Tr.AlreadyInWorktree)
}
// 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.c.Helpers().Repos.DispatchSwitchTo(worktree.Path, true, self.c.Tr.ErrWorktreeMovedOrDeleted)
return self.c.Helpers().Worktree.Switch(worktree)
}
func (self *WorktreesController) checkSelected(callback func(worktree *models.Worktree) error) func() error {