@@ -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