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
459 stars 88 forks source link

Does this extension really need Live Preview? #392

Open phiter opened 1 year ago

phiter commented 1 year ago

Hi! I have Live Preview and when trying to disable Live Preview, I get this warning that this extension depends on it. Is this a bug or an actual dependency?

image

ryanluker commented 1 year ago

Thanks for the issue @phiter! You are correct that this isn't a hard dependency but instead an optional one if you wish to use to view the coverage reports in vscode.

Preview Report (activated via command palette): Shows you a html preview of your coverage reports in your editor.

https://github.com/ryanluker/vscode-coverage-gutters#common-commands

After looking around the vscode repo, it seems like there is no ability to make an extension optional... https://github.com/microsoft/vscode/issues/6384

@mattseddon might have good insights or more thoughts, but there could also be other ways to using installed extensions without having to add the live server extension as a hard dependency 🤔.

mattseddon commented 1 year ago

AFAIK there are three options:

  1. Hard dependency.
  2. Rebuild the external extension's functionality internally.
  3. Check to see if dependency is installed, if not then prompt to install/explain why the dependant functionality doesn't currently work.

For 3 you can use something along the lines of:

import { extensions } from 'vscode'
...
export const isInstalled = (id: string): boolean =>
  !!extensions.all.some(extension => extension.id === id)

or around the boundary of https://github.com/ryanluker/vscode-coverage-gutters/blob/master/src/extension/gutters.ts#L48 you need to check if ms-vscode.live-server was returned and show a toast message (window.showErrorMessage or window.showWarningMessage, probably as a modal)/return early if it wasn't.

Hope that helps. Let me know if you need any more context or details.

ryanluker commented 1 year ago

AFAIK there are three options:

1. Hard dependency.

2. Rebuild the external extension's functionality internally.

3. Check to see if dependency is installed, if not then prompt to install/explain why the dependant functionality doesn't currently work.

For 3 you can use something along the lines of:

import { extensions } from 'vscode'
...
export const isInstalled = (id: string): boolean =>
  !!extensions.all.some(extension => extension.id === id)

or around the boundary of https://github.com/ryanluker/vscode-coverage-gutters/blob/master/src/extension/gutters.ts#L48 you need to check if ms-vscode.live-server was returned and show a toast message (window.showErrorMessage or window.showWarningMessage, probably as a modal)/return early if it wasn't.

Hope that helps. Let me know if you need any more context or details.

This helps a ton @mattseddon ! I kinda figured option 3 would be what we would need after I saw the 6+ year old ticket hah 😅.

cameronelliott commented 7 months ago

I really think Coverage Gutters is awesome, but was a bit surprised and disappointed that Live Preview can't be uninstalled while Coverage Gutters is installed. Thanks for making Coverage Gutters!

ryanluker commented 6 months ago

I really think Coverage Gutters is awesome, but was a bit surprised and disappointed that Live Preview can't be uninstalled while Coverage Gutters is installed. Thanks for making Coverage Gutters!

Thanks for the input! I felt similar when we were investigating the feature, but it was a vscode extension api limitation last time I checked 🤔. We probably need to implement one of Matt's suggestions above to get around this...