diff --git a/pkg/gui/controllers/commits_files_controller.go b/pkg/gui/controllers/commits_files_controller.go index da24b155c..6c8f49e1f 100644 --- a/pkg/gui/controllers/commits_files_controller.go +++ b/pkg/gui/controllers/commits_files_controller.go @@ -645,9 +645,13 @@ func isDescendentOfSelectedCommitFileNodes(node *filetree.CommitFileNode, select nodePath := node.GetInternalPath() for _, selectedNode := range selectedNodes { + if selectedNode.IsFile() { + continue + } + selectedNodePath := selectedNode.GetInternalPath() - if strings.HasPrefix(nodePath, selectedNodePath) && nodePath != selectedNodePath { + if strings.HasPrefix(nodePath, selectedNodePath+"/") { return true } } diff --git a/pkg/gui/controllers/files_controller.go b/pkg/gui/controllers/files_controller.go index 656da1bf5..567b0b6e5 100644 --- a/pkg/gui/controllers/files_controller.go +++ b/pkg/gui/controllers/files_controller.go @@ -1552,6 +1552,8 @@ func normalisedSelectedNodes(selectedNodes []*filetree.FileNode) []*filetree.Fil }) } +// NOTE: there's a duplicate of this function in commits_files_controller.go; if you make +// changes here, make them there, too. (We should unify them using generics.) func isDescendentOfSelectedNodes(node *filetree.FileNode, selectedNodes []*filetree.FileNode) bool { nodePath := node.GetInternalPath() diff --git a/pkg/integration/tests/patch_building/select_direcories_sharing_prefix.go b/pkg/integration/tests/patch_building/select_direcories_sharing_prefix.go index 2c0059dd0..bd20e4ff5 100644 --- a/pkg/integration/tests/patch_building/select_direcories_sharing_prefix.go +++ b/pkg/integration/tests/patch_building/select_direcories_sharing_prefix.go @@ -41,19 +41,13 @@ var SelectDirecoriesSharingPrefix = NewIntegrationTest(NewIntegrationTestArgs{ Equals(" ▼ foo").IsSelected(), Equals(" ● file").IsSelected(), Equals(" ▼ foobar").IsSelected(), - /* EXPECTED: Equals(" ● file"), - ACTUAL: */ - Equals(" A file"), ) t.Views().Information().Content(Contains("Building patch")) t.Views().Secondary().Content( - /* EXPECTED: Contains("foo/file").Contains("foobar/file"), - ACTUAL: */ - Contains("foo/file").DoesNotContain("foobar/file"), ) }, })