From fd65f094a5e1b93279358bf4db34719d6f0a0f5c Mon Sep 17 00:00:00 2001 From: "bobo.yang" Date: Tue, 19 Dec 2023 17:39:21 +0800 Subject: [PATCH] Fix string replacement syntax and closing parentheses in FunctionTestCodeLensProvider --- src/panel/codeLens.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/panel/codeLens.ts b/src/panel/codeLens.ts index 65cfa71..853404a 100644 --- a/src/panel/codeLens.ts +++ b/src/panel/codeLens.ts @@ -152,15 +152,16 @@ class FunctionTestCodeLensProvider implements vscode.CodeLensProvider { // Read range content in document const functionCode = document.getText(range); const parentRange = funcDef.containerRange; - const parentRangeStr = parentRange? `[${parentRange.start.line}, ${parentRange.end.line}]` : ""; - + // Fix the string replacement syntax and closing parentheses const prompt = codelenRegister.promptGenerator .replace('{__filename__}', document.uri.fsPath) .replace('{__functionName__}', funcDef.name) - .replace('{__functionRange__}', `[${range.start.line}, ${range.end.line}]`) + .replace('{__functionStartLine__}', `${range.start.line}`) + .replace('{__functionEndLine__}', `${range.end.line}`) .replace('{__containerName__}', funcDef.containerName || '') - .replace('{__containerRange__}', parentRangeStr) + .replace('{__containerStartLine__}', `${parentRange? parentRange.start.line : -1}`) + .replace('{__containerEndLine__}', `${parentRange? parentRange.end.line : -1}`) .replace('{__functionCode__}', functionCode); // Fixed syntax const lens = new vscode.CodeLens(range, {