Skip to content

Commit 1abf1d8

Browse files
Merge pull request #49 from gjsjohnmurray/fix-48
Improve method range highlighting accessed from coverage tree
2 parents 6ef52db + f53b07c commit 1abf1d8

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## 2.0.2 (dd-Mmm-2025)
1+
## 2.0.2 (30-Jul-2025)
22
* Fix coverage marking when `"objectscript.multilineMethodArgs": true` (#46)
3+
* Improve method range highlighting accessed from coverage tree (#48)
34

45
## 2.0.1 (28-Jul-2025)
56
* Activate the Covering Tests filter in the editor's Test Coverage Toolbar (#44)

src/ourFileCoverage.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,20 @@ export class OurFileCoverage extends vscode.FileCoverage {
131131
serverSpec,
132132
{ apiVersion: 1, namespace, path: "/action/query" },
133133
{
134-
query: "SELECT element_key StartLine, LineToMethodMap Method FROM TestCoverage_Data.CodeUnit_LineToMethodMap WHERE CodeUnit = ? ORDER BY StartLine",
134+
query: `
135+
SELECT clm.element_key AS StartLine,
136+
clm.LineToMethodMap AS Method,
137+
CASE
138+
WHEN md.Description IS NULL THEN 0
139+
ELSE $LENGTH(md.Description, CHAR(13))
140+
END AS DescriptionLineCount
141+
FROM TestCoverage_Data.CodeUnit_LineToMethodMap clm
142+
JOIN TestCoverage_Data.CodeUnit cu ON clm.CodeUnit = cu.Hash
143+
LEFT JOIN %Dictionary.MethodDefinition md ON md.Name = clm.LineToMethodMap
144+
AND md.parent = cu.Name
145+
WHERE clm.CodeUnit = ?
146+
ORDER BY StartLine
147+
`,
135148
parameters: [this.codeUnit],
136149
},
137150
);
@@ -143,15 +156,16 @@ export class OurFileCoverage extends vscode.FileCoverage {
143156
response?.data?.result?.content?.forEach(element => {
144157
const currentMethod = element.Method;
145158
const currentStartLine = Number(element.StartLine);
159+
const descriptionLineCount = Number(element.DescriptionLineCount);
146160
if (previousMethod && previousStartLine) {
147161
const start = new vscode.Position(previousStartLine - 1 + startOffset, 0);
148-
const end = new vscode.Position(currentStartLine - 2 + endOffset, Number.MAX_VALUE);
162+
const end = new vscode.Position(currentStartLine - 2 + endOffset - descriptionLineCount, Number.MAX_VALUE);
149163
detailedCoverage.push(new vscode.DeclarationCoverage(previousMethod, true, new vscode.Range(start, end)));
150164
}
151165
startOffset = endOffset;
152166
endOffset = (mapOffsets.get(currentMethod) || endOffset);
153167
previousMethod = currentMethod;
154-
previousStartLine = currentStartLine;
168+
previousStartLine = currentStartLine - descriptionLineCount;
155169
});
156170

157171
// Add the final method (if any)

0 commit comments

Comments
 (0)