@canyonjs/report-component 1.0.19 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +12 -9
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ const generateCoreDataForEachComponent = ({ dataSource, filenameKeywords, value,
48
48
 
49
49
  //#endregion
50
50
  //#region src/helpers/annotate.ts
51
- function annotateStatements(fileCoverage) {
51
+ function annotateStatements(fileCoverage, structuredText) {
52
52
  const annotateStatementsList = [];
53
53
  const statementStats = fileCoverage.s;
54
54
  const statementMeta = fileCoverage.statementMap;
@@ -59,13 +59,16 @@ function annotateStatements(fileCoverage) {
59
59
  const endCol = meta.end.column + 1;
60
60
  const startLine = meta.start.line;
61
61
  const endLine = meta.end.line;
62
- if (type === "no") annotateStatementsList.push({
63
- startLine,
64
- endLine,
65
- startCol: startCol + 1,
66
- endCol: endCol + 1,
67
- type: "S"
68
- });
62
+ if (type === "no") {
63
+ const realEndCol = startCol > endCol ? structuredText.split("\n")[startLine - 1].length : endCol;
64
+ annotateStatementsList.push({
65
+ startLine,
66
+ endLine,
67
+ startCol: startCol + 1,
68
+ endCol: realEndCol + 1,
69
+ type: "S"
70
+ });
71
+ }
69
72
  });
70
73
  return annotateStatementsList;
71
74
  }
@@ -644,7 +647,7 @@ const CoverageDetail = ({ source, coverage, diff }) => {
644
647
  editorRef.current = editor;
645
648
  const decorations = (() => {
646
649
  const all = [];
647
- const annotateStatementsList = annotateStatements(coverage);
650
+ const annotateStatementsList = annotateStatements(coverage, source);
648
651
  all.push(...annotateStatementsList);
649
652
  const annotateFunctionsList = annotateFunctions(coverage, source);
650
653
  all.push(...annotateFunctionsList);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canyonjs/report-component",
3
3
  "type": "module",
4
- "version": "1.0.19",
4
+ "version": "1.0.20",
5
5
  "author": "Travis Zhang<https://github.com/travzhang>",
6
6
  "repository": {
7
7
  "type": "git",