oleg-shilo / Favorites.vscode

VSCode extension for managing Favorites
MIT License
24 stars 6 forks source link

Unable to bookmark pdf or epub files #46

Open devgid opened 8 months ago

devgid commented 8 months ago

I have vscode-pdf extension to read pdf files and epub reader extension to read epub files.

When I click the bookmark icon on any of these type of open files (pdf or epub) I get the following error

image

If I right click on the file, copy path and paste the path into the extension's list text file manually, then the bookmark shows in the extension.

oleg-shilo commented 8 months ago

Will have a look. Txs

oleg-shilo commented 8 months ago

Unfortunately, it's not something that can be fixed. The API design of VSCode has a flaw. It does not allow you to map a document-derived tab (e.g. preview, pdf-renderer) to the file that was used as a source for that tab. As far as VSCode API goes it simply says there is no active editor at the moment:

image

I found this post, which triggered this discussion. The problem was highlighted in 2018 but VSCode team closed it in 2020 without addressing the file name aspect of it. I can't see how we can even have a workaround.

The only thing that I can do is to explain the problem better in the error message: image

devgid commented 8 months ago

@oleg-shilo Thanks for the explanation. Is it possible to add an "add to favorites" open in the context menu when right clicking on a file. This is how the another favorites extension I tested does it which works with epub and pdf files.

This is the favourite extension https://marketplace.visualstudio.com/items?itemName=kdcro101.favorites and the right context menu: image

oleg-shilo commented 8 months ago

Definitely. It means that the author of this extension has found a way to overcome this limitation. If indeed it is the case then it can be done even for the existing "add" button. Will have a look.

oleg-shilo commented 8 months ago

Done: Update the extension and you will be able to add the file via the context menu of the tab. 313953125-89b91bae-7267-4ba9-8a01-a80dd49ae110