From dd8d64781e22f2f319770f33a438b76bef0e10cc Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Fri, 13 Dec 2024 05:47:44 +0000 Subject: [PATCH] =?UTF-8?q?refactor:=20=E2=99=BB=EF=B8=8F=20improve=20scri?= =?UTF-8?q?pt=20file=20resolution=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/vscode/src/fragmentcommands.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/vscode/src/fragmentcommands.ts b/packages/vscode/src/fragmentcommands.ts index 533d6a194..bc65745a4 100644 --- a/packages/vscode/src/fragmentcommands.ts +++ b/packages/vscode/src/fragmentcommands.ts @@ -74,24 +74,26 @@ export function activateFragmentCommands(state: ExtensionState) { const { context, host } = state const { subscriptions } = context + const scriptFile = (p: PromptScript) => + state.host.path.isAbsolute(p.filename) + ? p.filename + : state.host.path.resolve(state.host.projectFolder(), p.filename) + const findScript = (filename: vscode.Uri) => { const fp = state.host.path.resolve(filename.fsPath) const scripts = state.project.scripts.filter((p) => !!p.filename) const script = scripts .filter((p) => !!p.filename) .find((p) => { - const pf = state.host.path.isAbsolute(p.filename) - ? p.filename - : state.host.path.resolve( - state.host.projectFolder(), - p.filename - ) - return pf === fp + const sfp = scriptFile(p) + return sfp === fp }) if (!script) { state.output.appendLine(`requested script: ${fp}`) - scripts.forEach((s) => state.output.appendLine(`- ${s.filename}`)) + scripts.forEach((s) => + state.output.appendLine(`- ${s.filename}\n ${scriptFile(s)}`) + ) const reportIssue = "Report Issue" vscode.window