Fix md references not checking authority

Simply compare by string for now
This commit is contained in:
Matt Bierner 2022-04-05 15:31:43 -07:00
parent a56c9f10b7
commit b4b7380576
No known key found for this signature in database
GPG key ID: 099C331567E11888
2 changed files with 4 additions and 2 deletions

View file

@ -162,7 +162,7 @@ export class MdReferencesProvider extends Disposable implements vscode.Reference
const references: MdReference[] = [];
for (const link of allLinksInWorkspace) {
if (link.href.kind === 'external' && link.href.uri.scheme === sourceLink.href.uri.scheme && link.href.uri.path === sourceLink.href.uri.path) {
if (link.href.kind === 'external' && link.href.uri.toString() === sourceLink.href.uri.toString()) {
const isTriggerLocation = sourceLink.source.resource.fsPath === link.source.resource.fsPath && sourceLink.source.hrefRange.isEqual(link.source.hrefRange);
references.push({
kind: 'link',

View file

@ -361,7 +361,7 @@ suite('markdown: find all references', () => {
);
});
test('Should consider paths when finding references to http uri', async () => {
test('Should consider authority, scheme and paths when finding references to http uri', async () => {
const uri = workspacePath('doc.md');
const doc = new InMemoryDocument(uri, joinLines(
`[1](http://example.com/cat)`,
@ -369,6 +369,8 @@ suite('markdown: find all references', () => {
`[3](http://example.com/dog)`,
`[4](http://example.com/cat/looong)`,
`[5](http://example.com/cat)`,
`[6](http://other.com/cat)`,
`[7](https://example.com/cat)`,
));
const refs = await getReferences(doc, new vscode.Position(0, 13), new InMemoryWorkspaceMarkdownDocuments([doc]));