From f078182ddcdf160a3783e41414b6f9aa1ced29d8 Mon Sep 17 00:00:00 2001 From: Mark Wiemer Date: Mon, 28 Oct 2024 19:48:42 -0700 Subject: [PATCH 01/24] Bump to latest ahk2 --- ahk2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ahk2 b/ahk2 index c05e25ed..16c0722e 160000 --- a/ahk2 +++ b/ahk2 @@ -1 +1 @@ -Subproject commit c05e25ede71fb57a15c9e1fa18606068a2a8a88e +Subproject commit 16c0722e2d176da1cacc976c823c8df139e1af50 From 07edad88495aa90fd6bac2a2183aaacf8dd370f6 Mon Sep 17 00:00:00 2001 From: Mark Wiemer Date: Mon, 28 Oct 2024 19:55:01 -0700 Subject: [PATCH 02/24] Replace substr with substring --- src/providers/defProvider.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/providers/defProvider.ts b/src/providers/defProvider.ts index 5fe5a558..b44af224 100644 --- a/src/providers/defProvider.ts +++ b/src/providers/defProvider.ts @@ -97,7 +97,10 @@ export class DefProvider implements vscode.DefinitionProvider { } const parent = workFolder ? workFolder - : document.uri.path.substr(0, document.uri.path.lastIndexOf('/')); + : document.uri.path.substring( + 0, + document.uri.path.lastIndexOf('/'), + ); const targetPath = vscode.Uri.file( includeMatch[0] .trim() From e5078e9337603b46ea259bbbb64f4b58d1c47ca6 Mon Sep 17 00:00:00 2001 From: Mark Wiemer Date: Mon, 28 Oct 2024 20:05:55 -0700 Subject: [PATCH 03/24] Document Out class --- src/common/out.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/common/out.ts b/src/common/out.ts index 56d185ea..a6b7aabf 100644 --- a/src/common/out.ts +++ b/src/common/out.ts @@ -4,6 +4,10 @@ import * as vscode from 'vscode'; export class Out { private static outputChannel: vscode.OutputChannel; + /** + * Logs the given value without focusing the output view. + * Prepends all logs with `new Date().toISOString()`. + */ public static debug(value: Error | string) { Out.log(value, false); } @@ -12,6 +16,7 @@ export class Out { * Logs the given value. Traces errors to console before logging. * Prepends all logs with `new Date().toISOString()`. * @param value The value to log + * @param focus whether to focus the output view. Defaults to true. */ public static log(value: Error | string, focus = true) { if (value instanceof Error) { From f2432c45d10680f7312ee41291d169f26646f3e6 Mon Sep 17 00:00:00 2001 From: Mark Wiemer Date: Mon, 28 Oct 2024 20:06:17 -0700 Subject: [PATCH 04/24] 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; } From fdf5b92632025834048a3893c57991fb99c02941 Mon Sep 17 00:00:00 2001 From: Mark Wiemer Date: Mon, 28 Oct 2024 20:10:00 -0700 Subject: [PATCH 05/24] Cleanup workFolder check in tryGetFileLink --- src/providers/defProvider.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/providers/defProvider.ts b/src/providers/defProvider.ts index e58762e9..59a2198f 100644 --- a/src/providers/defProvider.ts +++ b/src/providers/defProvider.ts @@ -106,12 +106,9 @@ export class DefProvider implements vscode.DefinitionProvider { if (!includeMatch) { return undefined; } - const parent = workFolder - ? workFolder - : document.uri.path.substring( - 0, - document.uri.path.lastIndexOf('/'), - ); + const parent = + workFolder || + document.uri.path.substring(0, document.uri.path.lastIndexOf('/')); const targetPath = vscode.Uri.file( includeMatch[0] .trim() From 4c21c61570cc9d37c540926cb52e13ffc6997654 Mon Sep 17 00:00:00 2001 From: Mark Wiemer Date: Tue, 29 Oct 2024 20:00:43 -0700 Subject: [PATCH 06/24] Identify cause of bug --- src/parser/parser.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/parser/parser.ts b/src/parser/parser.ts index 7c1a17d8..873b3d01 100644 --- a/src/parser/parser.ts +++ b/src/parser/parser.ts @@ -53,6 +53,7 @@ export class Parser { document: vscode.TextDocument, options: BuildScriptOptions = {}, ): Promise