mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-26 07:00:16 -05:00
Extract worktreeOfFile from markWorktreeFiles
The files panel is going to need to find the worktree of an entry too. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
875641557b
commit
3ffcc0c7b0
1 file changed
+10
-4
@@ -1476,10 +1476,7 @@ func markWorktreeFiles(files []*models.File, worktrees []*models.Worktree, workt
|
||||
changed := false
|
||||
|
||||
for _, file := range files {
|
||||
absPath := filepath.Join(worktreePath, file.Path)
|
||||
isWorktree := lo.SomeBy(worktrees, func(worktree *models.Worktree) bool {
|
||||
return worktree.Path == absPath
|
||||
})
|
||||
_, isWorktree := worktreeOfFile(file, worktrees, worktreePath)
|
||||
|
||||
if isWorktree != file.IsWorktree {
|
||||
file.IsWorktree = isWorktree
|
||||
@@ -1490,6 +1487,15 @@ func markWorktreeFiles(files []*models.File, worktrees []*models.Worktree, workt
|
||||
return changed
|
||||
}
|
||||
|
||||
// worktreeOfFile returns the worktree that an entry of the files panel is, if
|
||||
// it is one. worktreePath is the path of the worktree that we're in.
|
||||
func worktreeOfFile(file *models.File, worktrees []*models.Worktree, worktreePath string) (*models.Worktree, bool) {
|
||||
absPath := filepath.Join(worktreePath, file.Path)
|
||||
return lo.Find(worktrees, func(worktree *models.Worktree) bool {
|
||||
return worktree.Path == absPath
|
||||
})
|
||||
}
|
||||
|
||||
// the reflogs panel is the only panel where we cache data, in that we only
|
||||
// load entries that have been created since we last ran the call. This means
|
||||
// we need to be more careful with how we use this, and to ensure we're emptying
|
||||
|
||||
Reference in new issue
Block a user