Skip to content

Commit 081c672

Browse files
committed
Update documentIndex.ts
1 parent f8612ba commit 081c672

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/utils/documentIndex.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,10 @@ export function inferDocName(uri: vscode.Uri): string | undefined {
462462
}
463463
});
464464
if (!containingPaths.size) return; // We couldn't learn anything from the documents in the index
465-
// Sort the values in the Set by number of segments descending so we check the deepest paths first
465+
// Sort the values in the Set by length descending so we check child directories before their parents.
466+
// This ensures that we use the mapping of a document that is as close a neighbor as possible. This
467+
// is necessary for the rare situaions for documents in /foo/bar/ have a different mapping than /foo/
468+
// and the target URI is in /foo/bar/ or a subfolder of it.
466469
const containingPathsSorted = Array.from(containingPaths).sort((a, b) => b.length - a.length);
467470
let result: string;
468471
for (const prefix of containingPathsSorted) {

0 commit comments

Comments
 (0)