diff --git a/pkg/commands/patch/patch_manager.go b/pkg/commands/patch/patch_manager.go index ccb2a1081..3d6a076e8 100644 --- a/pkg/commands/patch/patch_manager.go +++ b/pkg/commands/patch/patch_manager.go @@ -222,7 +222,11 @@ func (p *PatchManager) RenderAggregatedPatchColored(plain bool) string { return result } -func (p *PatchManager) GetFileStatus(filename string) PatchStatus { +func (p *PatchManager) GetFileStatus(filename string, parent string) PatchStatus { + if parent != p.To { + return UNSELECTED + } + info, ok := p.fileInfoMap[filename] if !ok { return UNSELECTED diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index 6a7baad2f..511d31b3d 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -148,7 +148,7 @@ func (gui *Gui) handleToggleFileForPatch(g *gocui.Gui, v *gocui.View) error { // if there is any file that hasn't been fully added we'll fully add everything, // otherwise we'll remove everything adding := node.AnyFile(func(file *models.CommitFile) bool { - return gui.GitCommand.PatchManager.GetFileStatus(file.Name) != patch.WHOLE + return gui.GitCommand.PatchManager.GetFileStatus(file.Name, gui.State.CommitFileChangeManager.GetParent()) != patch.WHOLE }) err := node.ForEachFile(func(file *models.CommitFile) error { diff --git a/pkg/gui/filetree/commit_file_change_manager.go b/pkg/gui/filetree/commit_file_change_manager.go index 669235ef6..48754e5de 100644 --- a/pkg/gui/filetree/commit_file_change_manager.go +++ b/pkg/gui/filetree/commit_file_change_manager.go @@ -91,6 +91,6 @@ func (m *CommitFileChangeManager) ToggleCollapsed(path string) { func (m *CommitFileChangeManager) Render(diffName string, patchManager *patch.PatchManager) []string { return renderAux(m.tree, m.collapsedPaths, "", -1, func(n INode, depth int) string { castN := n.(*CommitFileChangeNode) - return presentation.GetCommitFileLine(castN.NameAtDepth(depth), diffName, castN.File, patchManager) + return presentation.GetCommitFileLine(castN.NameAtDepth(depth), diffName, castN.File, patchManager, m.parent) }) } diff --git a/pkg/gui/presentation/commit_files.go b/pkg/gui/presentation/commit_files.go index bf8b6243b..4980f6c50 100644 --- a/pkg/gui/presentation/commit_files.go +++ b/pkg/gui/presentation/commit_files.go @@ -8,7 +8,7 @@ import ( "github.com/jesseduffield/lazygit/pkg/utils" ) -func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFile, patchManager *patch.PatchManager) string { +func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFile, patchManager *patch.PatchManager, parent string) string { yellow := color.New(color.FgYellow) green := color.New(color.FgGreen) defaultColor := color.New(theme.DefaultTextColor) @@ -22,7 +22,7 @@ func GetCommitFileLine(name string, diffName string, commitFile *models.CommitFi if diffName == name { colour = diffTerminalColor } else if commitFile != nil { - status := patchManager.GetFileStatus(commitFile.Name) + status := patchManager.GetFileStatus(commitFile.Name, parent) switch status { case patch.UNSELECTED: colour = defaultColor