diff --git a/lib/coverage.js b/lib/coverage.js index 8408516bd..3885380c9 100644 --- a/lib/coverage.js +++ b/lib/coverage.js @@ -189,7 +189,12 @@ module.exports = inherit({ }.bind(this), coverageLevel.NONE); var sourceStart = getPosition(rule.position.start, opts.url, opts.map), - sourceEnd = getPosition(rule.position.end, opts.url, opts.map), + // We're using the start of the last declaration here instead of the + // rule.position.end, because due for example to the use of sass + // variables and a buggy implementation of sourcemaps in both ruby sass + // as well as lib sass the rule end would map to the end of the variable + // declaration instead of the correct end of the css rule + sourceEnd = getPosition(rule.declarations[rule.declarations.length - 1].position.start, opts.url, opts.map), // Synchronous realpath() is used because of original method is totally synchronous and recursive, // while the order of recursive calls is important. Making the code being asynchronous won't make // much benefit considering only one async call can be executed to guarantee the calling order.