oleg-shilo / Favorites.vscode

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

"Scheme contains illegal characters" #41

Closed TulsaMJ closed 1 year ago

TulsaMJ commented 2 years ago

I've been using Favorites (and loving it, so thanks!!) for many months now. Recently my favorites list blanked out - the *.list.txt files are still there, and apparently the default list is even loading up, but I can't see them. When I attempt to refresh the list, at the bottom of the screen I get a popup error "[UriError]: Scheme contains illegal characters." I've tried reverting to earlier versions of the extension, and that doesn't seem to solve the problem so presumably something changed in my environment that I need to fix. Any idea why that might happen, or what I could try to troubleshoot and solve it? I haven't even had any luck figuring out what a "Scheme" is in VS Code.

oleg-shilo commented 2 years ago

Hi @TulsaMJ,

I think it might be related to the recent new feature support for the remote files in the list. The feature was implemented upon user request but the initial user feedback indicated some problems with storing the URI-based and local paths in the same favourites list. file:///C:/test.log vs C:\test.log

Thus I had to release very quickly the adjustment top the feature so the local files are stored in a pure local form. Thus if accidentally your lists were converted into the URI file schema before the latest release was installed the behaviour as you described could be observed. Unless of course, indeed your problem is caused by some local environment reasons.

Anyway, you can easily check it. Just open your list file and ensure that you do not have any URI path items (e.g. file:\, vs-code:\). If you find them then convert to a normal local path manually.

This will help or at least eliminate this possible reason.

...what a "Scheme" is in VS Code.

URI = scheme ":" ["//" authority] path ["?" query] ["#" fragment] In file:///C:/test.log the scheme value is file

TulsaMJ commented 2 years ago

Thanks, that was really helpful in getting me back on the road troubleshooting! I'm actually in a Linux environment (we use Macs but all of our VS Code projects and files are on a Linux server). My paths look more like:

/home/users/my.username/.config/Code/User/favorites.user/Favorites.list.txt

I was able briefly to get my favorites lists to load up by changing the Data Location in the VS Code configurations from "" to the actual file and then following the link to "Workspace" and made the same change there - after that I restarted VS Code and could see my favorites until I tried to switch to another favorites file, at which point they disappeared again. I did look through all of my favorites files and then all start with /home/users/* like the one above.

I'm wondering if it could have to do with my practice of some lines just having text strings on them (such as "Files related to ordering"). I'm wondering if the current version of the code is interpreting those as URIs. Now it seems like I can install an old version and after a restart, things work fine until the extension gets updated.

oleg-shilo commented 2 years ago

Hm... So when saving the list the extension is losing the list items :(

It is definitely not related to the comments you put there. I tested it: image

I am puzzled as switching the active list does not trigger saving to file. Thus I see no trigger for writing to the list file and potentially messing with its content.

I cannot reproduce it. I have no other reports about it to get any extra information. :(

Is it too much to ask you to see what is happening under debugger? The only routine that is writing to the list file is write_all_lines (utils.ts:591). If you put a breakpoint there and debug you will be able to see what is causing the problem.

TulsaMJ commented 1 year ago

Hi Oleg - sorry I never got back to you on this, but I've figured out what was causing the error. I had been putting comment lines in my favorites files without preceding them with the vertical bar:

Here is my comment

Instead of the correct way:

| Here is my comment

I think maybe that was the correct way to do it in earlier versions? Anyway, that wasn't the specific problem. The problem was using a colon in my comment.

This works fine:

| The following links are for the Archer project:

This throws the error:

The following links are for the Archer project:

I suspect the code sees the colon, assumes it has found a URI, but then its head explodes because it's not a real URI scheme. So I've fixed it for myself, and I'm going to close this ticket - I just wanted to leave it here in case someone else makes the same mistake I made.

oleg-shilo commented 1 year ago

Great, thank you for sharing your findings