Fix explicit references to own file

This commit is contained in:
Matt Bierner
2022-04-01 00:03:40 -07:00
parent a7ba4439ae
commit 114b340f7a
4 changed files with 79 additions and 5 deletions

View File

@@ -218,8 +218,8 @@ export class MdReferencesProvider extends Disposable implements vscode.Reference
}
} else { // Triggered on a link without a fragment so we only require matching the file and ignore fragments
// But exclude cases where the file is referencing itself
if (link.sourceResource.fsPath !== targetDoc.uri.fsPath) {
// But exclude cases where the file is implicitly referencing itself
if (!link.sourceText.startsWith('#') || link.sourceResource.fsPath !== targetDoc.uri.fsPath) {
references.push({
kind: 'link',
isTriggerLocation,

View File

@@ -56,7 +56,10 @@ export class MdRenameProvider extends Disposable implements vscode.RenameProvide
return triggerRef.link.sourceHrefRange;
}
} else {
return triggerRef.fragmentLocation?.range ?? triggerRef.location.range;
if (triggerRef.fragmentLocation) {
return triggerRef.fragmentLocation.range;
}
throw new Error(localize('renameNoFiles', "Renaming files is currently not supported"));
}
}
}