From f2432c45d10680f7312ee41291d169f26646f3e6 Mon Sep 17 00:00:00 2001 From: Mark Wiemer Date: Mon, 28 Oct 2024 20:06:17 -0700 Subject: [PATCH] Add logs and documentation to tryGetFileLink --- src/providers/defProvider.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/providers/defProvider.ts b/src/providers/defProvider.ts index b44af224..e58762e9 100644 --- a/src/providers/defProvider.ts +++ b/src/providers/defProvider.ts @@ -1,6 +1,7 @@ import * as vscode from 'vscode'; import { Parser } from '../parser/parser'; import { existsSync } from 'fs'; +import { Out } from '../common/out'; export class DefProvider implements vscode.DefinitionProvider { public async provideDefinition( @@ -85,13 +86,23 @@ export class DefProvider implements vscode.DefinitionProvider { return null; } + /** + * If the position is on an `#Include` line, + * returns a Location at the beginning of the included file. + * Otherwise returns undefined. + */ public async tryGetFileLink( document: vscode.TextDocument, position: vscode.Position, workFolder?: string, ): Promise | undefined { + const funcName = 'tryGetFileLink'; const { text } = document.lineAt(position.line); - const includeMatch = text.match(/(?<=#include).+?\.(ahk|ext)\b/i); + Out.debug(`${funcName} text: ${text}`); + const includeMatch = text.match( + /(?<=#include).+?\.(ahk|ahk1|ah1|ext)\b/i, + ); + Out.debug(`${funcName} includeMatch: ${includeMatch?.[0]}`); if (!includeMatch) { return undefined; }