diff options
Diffstat (limited to 'extensions/markdown-language-features/src/languageFeatures/definitionProvider.ts')
-rw-r--r-- | extensions/markdown-language-features/src/languageFeatures/definitionProvider.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/extensions/markdown-language-features/src/languageFeatures/definitionProvider.ts b/extensions/markdown-language-features/src/languageFeatures/definitionProvider.ts new file mode 100644 index 00000000000..622d6bf87a6 --- /dev/null +++ b/extensions/markdown-language-features/src/languageFeatures/definitionProvider.ts @@ -0,0 +1,21 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +import * as vscode from 'vscode'; +import { Disposable } from '../util/dispose'; +import { SkinnyTextDocument } from '../workspaceContents'; +import { MdReferencesProvider } from './references'; + +export class MdDefinitionProvider extends Disposable implements vscode.DefinitionProvider { + + constructor(private readonly referencesProvider: MdReferencesProvider) { + super(); + } + + async provideDefinition(document: SkinnyTextDocument, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.Definition | undefined> { + const allRefs = await this.referencesProvider.getAllReferencesAtPosition(document, position, token); + + return allRefs.find(ref => ref.kind === 'link' && ref.isDefinition)?.location; + } +} |