Skip to content

Commit d56ffb2

Browse files
committed
Update documentIndex.ts
1 parent 38f8e45 commit d56ffb2

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/utils/documentIndex.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -450,14 +450,14 @@ export function inferDocName(uri: vscode.Uri): string | undefined {
450450
index.uris.forEach((docName, docUriStr) => {
451451
const docExt = docName.slice(-4);
452452
if (exts.includes(docExt)) {
453-
const docUri = vscode.Uri.parse(docUriStr);
454453
// This entry is for a class or routine so see if its name and file system path match
455454
const docNamePath = `/${docName.slice(0, -4).replaceAll(".", "/")}${docExt}`;
456455
// Make sure the file extension is lowercased in the path before matching
457-
const startOfDocName = (docUri.path.slice(0, -3) + docUri.path.slice(-3).toLowerCase()).lastIndexOf(docNamePath);
458-
if (startOfDocName > -1) {
456+
let fullPath = vscode.Uri.parse(docUriStr).path;
457+
fullPath = fullPath.slice(0, -3) + fullPath.slice(-3).toLowerCase();
458+
if (fullPath.endsWith(docNamePath)) {
459459
// The document name is the trailing substring of the file system path with different delimiters
460-
containingPaths.add(docUri.path.slice(0, startOfDocName + 1));
460+
containingPaths.add(fullPath.slice(0, -docNamePath.length + 1));
461461
}
462462
}
463463
});

0 commit comments

Comments
 (0)