diff --git a/CHANGELOG.md b/CHANGELOG.md index 48323db..2037f38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ -## 2.0.2 (dd-Mmm-2025) +## 2.0.2 (30-Jul-2025) * Fix coverage marking when `"objectscript.multilineMethodArgs": true` (#46) +* Improve method range highlighting accessed from coverage tree (#48) ## 2.0.1 (28-Jul-2025) * Activate the Covering Tests filter in the editor's Test Coverage Toolbar (#44) diff --git a/src/ourFileCoverage.ts b/src/ourFileCoverage.ts index 56e0931..1df5210 100644 --- a/src/ourFileCoverage.ts +++ b/src/ourFileCoverage.ts @@ -131,7 +131,20 @@ export class OurFileCoverage extends vscode.FileCoverage { serverSpec, { apiVersion: 1, namespace, path: "/action/query" }, { - query: "SELECT element_key StartLine, LineToMethodMap Method FROM TestCoverage_Data.CodeUnit_LineToMethodMap WHERE CodeUnit = ? ORDER BY StartLine", + query: ` +SELECT clm.element_key AS StartLine, + clm.LineToMethodMap AS Method, + CASE + WHEN md.Description IS NULL THEN 0 + ELSE $LENGTH(md.Description, CHAR(13)) + END AS DescriptionLineCount +FROM TestCoverage_Data.CodeUnit_LineToMethodMap clm + JOIN TestCoverage_Data.CodeUnit cu ON clm.CodeUnit = cu.Hash + LEFT JOIN %Dictionary.MethodDefinition md ON md.Name = clm.LineToMethodMap + AND md.parent = cu.Name +WHERE clm.CodeUnit = ? +ORDER BY StartLine + `, parameters: [this.codeUnit], }, ); @@ -143,15 +156,16 @@ export class OurFileCoverage extends vscode.FileCoverage { response?.data?.result?.content?.forEach(element => { const currentMethod = element.Method; const currentStartLine = Number(element.StartLine); + const descriptionLineCount = Number(element.DescriptionLineCount); if (previousMethod && previousStartLine) { const start = new vscode.Position(previousStartLine - 1 + startOffset, 0); - const end = new vscode.Position(currentStartLine - 2 + endOffset, Number.MAX_VALUE); + const end = new vscode.Position(currentStartLine - 2 + endOffset - descriptionLineCount, Number.MAX_VALUE); detailedCoverage.push(new vscode.DeclarationCoverage(previousMethod, true, new vscode.Range(start, end))); } startOffset = endOffset; endOffset = (mapOffsets.get(currentMethod) || endOffset); previousMethod = currentMethod; - previousStartLine = currentStartLine; + previousStartLine = currentStartLine - descriptionLineCount; }); // Add the final method (if any)