Merge pull request #367 from devchat-ai/update_codelens

Fix string replacement syntax and closing
This commit is contained in:
boob.yang 2023-12-19 17:42:00 +08:00 committed by GitHub
commit 2e5c8f935d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -152,15 +152,16 @@ class FunctionTestCodeLensProvider implements vscode.CodeLensProvider {
// Read range content in document // Read range content in document
const functionCode = document.getText(range); const functionCode = document.getText(range);
const parentRange = funcDef.containerRange; const parentRange = funcDef.containerRange;
const parentRangeStr = parentRange? `[${parentRange.start.line}, ${parentRange.end.line}]` : "";
// Fix the string replacement syntax and closing parentheses // Fix the string replacement syntax and closing parentheses
const prompt = codelenRegister.promptGenerator const prompt = codelenRegister.promptGenerator
.replace('{__filename__}', document.uri.fsPath) .replace('{__filename__}', document.uri.fsPath)
.replace('{__functionName__}', funcDef.name) .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('{__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 .replace('{__functionCode__}', functionCode); // Fixed syntax
const lens = new vscode.CodeLens(range, { const lens = new vscode.CodeLens(range, {