ryanluker / vscode-coverage-gutters

Display test coverage generated by lcov and xml - works with many languages
https://marketplace.visualstudio.com/items?itemName=ryanluker.vscode-coverage-gutters
MIT License
460 stars 88 forks source link

convert relative paths from lcov output to absolute paths #173

Closed karn09 closed 5 years ago

karn09 commented 5 years ago

When an LCOV file contains paths relative to the project, the opened document will not be highlighted.

For example, transforming the below: SF:/home/ryanluker/dev/vscode-coverage-gutters/example/node/test.js

to: SF:./example/node/test.js

Will cause test.js to not be found, which results in coverage not being highlighted.

This addition attempts to search for absolute paths only when the provided path is relative, otherwise it will return the already known possiblePath.

Instead of searching through the various workspace folder globs, this will inspect the currently open documents made available via workspace.textDocuments.

karn09 commented 5 years ago

This may partially address https://github.com/ryanluker/vscode-coverage-gutters/issues/160

Also, the build errors are odd: Error: Extensionryanluker.vscode-coverage-guttersis not known or not activated

Seems unrelated to these changes.

ryanluker commented 5 years ago

@karn09 thanks for the PR! I rebuilt the branch as sometimes the integration / acceptance tests fail due to the container not downloading dependent resources in time, it is passing now.

I really like the way you are detecting the partial paths so I was thinking of modifying this a bit over the weekend to be always used with every parser type and remove my old version. {1}

{1} https://github.com/ryanluker/vscode-coverage-gutters/blob/26742f7d4bd8d84c0cd8c71c416819322ed9cfd9/src/files/coverageparser.ts#L95-L121

ryanluker commented 5 years ago

@karn09 going to continue the work on my branch for this, thanks again for kicking off this bug fix :+1: https://github.com/ryanluker/vscode-coverage-gutters/pull/177

karn09 commented 5 years ago

Thanks for taking a look at the PR! I just saw your new update. I had initially thought it was odd that ALL folders were being checked since I was using display gutters on a per file basis, and hadn't considered that this was meant to apply gutters to ALL files. Whether they were open currently or not.

Happy to see that this inspired changes, which totally fixes my original issue!

ryanluker commented 5 years ago

@karn09 Yah the display gutters uses the exact some modules as the watch functionality to keep the code dry and reasonable, so when you display coverage on a page it will load the coverage from the file system while the watch feature will reuse the cache (after the first load) for every new file opened.

karn09 commented 5 years ago

@ryanluker very cool! It took me some to unravel, but that makes a lot of sense. Thanks for explaining!