File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 ) {
You can’t perform that action at this time.
0 commit comments