Better message for markdown reference links (#151018)

Fixes #151017

Also improves the diagnostic message for invalid reference links to make it clear we are talking about a missing link definition
This commit is contained in:
Matt Bierner 2022-06-01 12:01:36 -07:00 committed by GitHub
parent 2664c7ddfd
commit 7477efd87e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -448,7 +448,7 @@ export class DiagnosticComputer {
if (link.href.kind === 'reference' && !definitionSet.lookup(link.href.ref)) {
yield new vscode.Diagnostic(
link.source.hrefRange,
localize('invalidReferenceLink', 'No link reference found: \'{0}\'', link.href.ref),
localize('invalidReferenceLink', 'No link definition found: \'{0}\'', link.href.ref),
severity);
}
}

View file

@ -271,9 +271,11 @@ export class MdLinkProvider implements vscode.DocumentLinkProvider {
case 'reference': {
const def = definitionSet.lookup(link.href.ref);
if (def) {
return new vscode.DocumentLink(
const documentLink = new vscode.DocumentLink(
link.source.hrefRange,
vscode.Uri.parse(`command:_markdown.moveCursorToPosition?${encodeURIComponent(JSON.stringify([def.source.hrefRange.start.line, def.source.hrefRange.start.character]))}`));
documentLink.tooltip = localize('documentLink.referenceTooltip', 'Go to link definition');
return documentLink;
} else {
return undefined;
}