mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 05:19:39 +00:00
Markdown ignoreLink should apply to paths in header links (#150223)
This change lets you ignore all links to a given file, even if those links include a header. For example: `[text](/path/to/file#some-header)` can be ignored using `/path/to/file`
This commit is contained in:
parent
6a9108155f
commit
1c7991f1e8
|
@ -494,7 +494,7 @@ export class DiagnosticComputer {
|
|||
if (fragmentLinks.length) {
|
||||
const toc = await TableOfContents.create(this.engine, hrefDoc);
|
||||
for (const link of fragmentLinks) {
|
||||
if (!toc.lookup(link.fragment) && !this.isIgnoredLink(options, link.source.text)) {
|
||||
if (!toc.lookup(link.fragment) && !this.isIgnoredLink(options, link.source.pathText) && !this.isIgnoredLink(options, link.source.text)) {
|
||||
const msg = localize('invalidLinkToHeaderInOtherFile', 'Header does not exist in file: {0}', link.fragment);
|
||||
diagnostics.push(new LinkDoesNotExistDiagnostic(link.source.hrefRange, msg, severity, link.source.text));
|
||||
}
|
||||
|
|
|
@ -256,4 +256,16 @@ suite('markdown: Diagnostics', () => {
|
|||
assert.deepStrictEqual(diagnostics.length, 0);
|
||||
}
|
||||
});
|
||||
|
||||
test('ignoreLinks should support ignore header links if file is ignored', async () => {
|
||||
const doc1 = new InMemoryDocument(workspacePath('doc1.md'), joinLines(
|
||||
`![i](/doc2.md#no-such)`,
|
||||
));
|
||||
const doc2 = new InMemoryDocument(workspacePath('doc2.md'), joinLines(''));
|
||||
|
||||
const contents = new InMemoryWorkspaceMarkdownDocuments([doc1, doc2]);
|
||||
const manager = createDiagnosticsManager(contents, new MemoryDiagnosticConfiguration(true, ['/doc2.md']));
|
||||
const { diagnostics } = await manager.recomputeDiagnosticState(doc1, noopToken);
|
||||
assert.deepStrictEqual(diagnostics.length, 0);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue