Skip to content

Commit e522aab

Browse files
committed
Refine path condensation to consider all parent directories for more comprehensive grouping
1 parent 0240a7f commit e522aab

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

packages/vscode/src/commands/save-context-command.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,16 @@ function condense_paths(
103103

104104
const condensed_paths = new Set(relative_paths)
105105

106-
const directories = Array.from(dir_to_children.keys())
106+
const all_dirs_set = new Set<string>()
107+
for (const dir of dir_to_children.keys()) {
108+
let current_dir = dir
109+
while (current_dir != '.' && current_dir != '/') {
110+
all_dirs_set.add(current_dir)
111+
current_dir = path.dirname(current_dir)
112+
}
113+
}
114+
115+
const directories = Array.from(all_dirs_set)
107116
directories.sort(
108117
(a, b) => b.split(path.sep).length - a.split(path.sep).length
109118
)
@@ -113,7 +122,7 @@ function condense_paths(
113122
if (dir == '.') continue
114123

115124
if (are_all_files_selected(dir, condensed_paths)) {
116-
for (const file of dir_to_children.get(dir)!) {
125+
for (const file of dir_to_children.get(dir) || []) {
117126
condensed_paths.delete(file)
118127
}
119128

0 commit comments

Comments
 (0)