Skip to content

Commit a0af908

Browse files
committed
Fix GetCommonParents
1 parent 0761a15 commit a0af908

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

internal/tspath/path.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,8 +1073,6 @@ func getCommonParentsWorker(componentGroups [][]string, minComponents int, optio
10731073
}
10741074

10751075
equality := options.getEqualityComparer()
1076-
var lastCommonIndex int
1077-
outer:
10781076
for lastCommonIndex := range maxDepth {
10791077
candidate := componentGroups[0][lastCommonIndex]
10801078
for j, comps := range componentGroups[1:] {
@@ -1095,25 +1093,25 @@ outer:
10951093
head []string
10961094
tails [][]string
10971095
}{
1098-
head: g[:lastCommonIndex],
1099-
tails: append(newGroups[key].tails, g[lastCommonIndex:]),
1096+
head: g[:lastCommonIndex+1],
1097+
tails: append(newGroups[key].tails, g[lastCommonIndex+1:]),
11001098
}
11011099
}
11021100
slices.Sort(orderedGroups)
11031101
result := make([][]string, 0, len(newGroups))
11041102
for _, key := range orderedGroups {
11051103
group := newGroups[key]
1106-
subResults := getCommonParentsWorker(group.tails, minComponents-lastCommonIndex, options)
1104+
subResults := getCommonParentsWorker(group.tails, minComponents-(lastCommonIndex+1), options)
11071105
for _, sr := range subResults {
11081106
result = append(result, append(group.head, sr...))
11091107
}
11101108
}
11111109
return result
11121110
}
1113-
break outer
1111+
return [][]string{componentGroups[0][:lastCommonIndex]}
11141112
}
11151113
}
11161114
}
11171115

1118-
return [][]string{componentGroups[0][:lastCommonIndex]}
1116+
return [][]string{componentGroups[0][:maxDepth]}
11191117
}

0 commit comments

Comments
 (0)