Skip to content

Improve method range highlighting accessed from coverage tree #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
20 changes: 17 additions & 3 deletions src/ourFileCoverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
},
);
Expand All @@ -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)
Expand Down
Loading