oleg-shilo / Favorites.vscode

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

If `'Data Location'` is set `<default>`, the `favorites.user` folder could be created within portable path (e.g. '..\globalStorage\favorites.user`) #37

Open carloscadux opened 2 years ago

carloscadux commented 2 years ago

Hey Oleg,

The path ${execPath}\..\[userfolder] you just implemented Issue #33 is perfect already for improving the portability experience of VSCode.

Just thinking further about full portability of VSCode out of the box, I'd suggest when Favorites extension is run from a VSCode portable instance and 'Data Location' is set <default>, the favorites.user folder could be created within the portable path, for instance under data\user-data\User\globalStorage\favorites.user.

I just tested the last release v1.5.13, and even I ran VSCode portable, the extension has created its default storage under roaming C:\Users\%username%\AppData\Roaming\Code\User\favorites.user

I've noticed that by default many extensions are creating their storage under the portable globalStorage folder, and my suggestion is aligned with that idea of a full VSCode portability experience.

Thank you, Carlos

oleg-shilo commented 2 years ago

Hm....

It supposed to do exactly what you described:

 ///////////////////////////////////////
    let extensionRoot = path.dirname(path.dirname(path.dirname(__dirname)));
    let isPortable = path.basename(extensionRoot).toLowerCase() == "data" || path.basename(extensionRoot).toLowerCase() == "code-portable-data";
    ///////////////////////////////////////

    if (isPortable) {
        return path.join(extensionRoot, 'user-data', 'User', 'favorites.user');
    } else { . . . 

Meaning that for some reason it's not detecting that it is portable. Will need to check again

oleg-shilo commented 2 years ago

Can you check if your portable has <vscode_root>/data || <vscode_root>/code-portable-data

The very latest portable download cannot start for me for some reason :(

carloscadux commented 2 years ago

Can you check if your portable has <vscode_root>/data || <vscode_root>/code-portable-data

I just created a clean portable installation (v1.65.2) having <vscode_root>/data Then I installed and ran your extension, which is still pointing to C:\Users\%username%\AppData\Roaming\Code\User\favorites.user I recorded all this test here: https://bit.ly/3HY7xIx

oleg-shilo commented 2 years ago

Thank you, it helped.

Indeed it was a problem with the `IsPortable detection algorithm, It was based on the extension location but a more reliable approach is to do it by code.exe location.

I have updated the extension but do not want to publish it on the marketplace until it is fully verified. Can you please test the release v1.5.14 by loading the extension from the file ("Install from VSIX").

carloscadux commented 2 years ago

Can you please test the release v1.5.14 by loading the extension from the file ("Install from VSIX").

Tested. Thanks for the improvements!

A couple of comments:

a) "Fixed faulty IsPortable detection" Fixed. The extension main folder is created in \data\user-data\User\globalStorage\favorites.user

b) "Added context menu for setting alias" I could set aliases for favorited folders properly. However, there is an error message when setting aliases for files which were favorited through the extension GUI: You can set alias only to file or folder items. The issue is that when adding 'active document to favorites' through the GUI it is inserted in the favorite list having this path format: file:///c%3A/_Data/_DataProg/_DataProg_TEST/File1.txt If I add files to the favorite list manually, using the standard path copied through Windows Explorer, the alias functionality works: C:\_Data\_DataProg\_DataProg_TEST\File1.txt

c) File theme icons Because of the same issue described in (b), files added through the GUI aren't showing the theme icons. When I add manually the files to the list using the default Windows Explorer path, the file theme icons are appearing properly.

d) Folder theme icons Folder theme icons aren't appearing anymore, even if added manually to the list using the default Windows Explorer path.

If you need further testing, just let me know.

oleg-shilo commented 2 years ago

Txs, will process it on weekend

oleg-shilo commented 2 years ago

My apologies. COVID had other plans. Only now I was able to address it. https://github.com/oleg-shilo/Favorites.vscode/releases/tag/v1.5.15

It was actually harder than I thought. The problem was that all extension business logic is based on fs module for all file system operations. And it does not support URI so quite a few conversions needed to be made.

Carlos, can I ask you to test it again please before I publish it on marketplace

oleg-shilo commented 2 years ago

Done. Published on Market Plase