janisdd / vscode-edit-csv

vs code extension to edit csv files with an excel like table ui
MIT License
215 stars 32 forks source link

Fix instance comparison #134

Closed ceribe closed 1 year ago

ceribe commented 1 year ago

How to replicate the bug:

  1. Open a csv file, let's call it file.csv.
  2. Click on "edit csv", editor will open.
  3. Close the original file.csv.
  4. Open file.csv again.
  5. Click on "edit csv" there.
  6. Error message will pop up in the bottom right and a second editor will try opening but will fail.

This is caused by comparison function used when finding instances. Comparing objects with === only checks for reference equality. If we open the same file twice then both uri objects will have the same content, but their references will be different. The fix in this PR makes it work by changing how uri objects are compared. Comparing path should do the job well enough, but if there is something I'm missing then using .toString() should fix the problem too.

janisdd commented 1 year ago

Thanks for the PR! Never thought about this... I'll check this and merge it today or tomorrow.

janisdd commented 1 year ago

@ceribe can you change it to .toString()? I think this is better, as the vs code team also uses toString. https://github.com/microsoft/vscode/blob/93cbbc5cae50e9f5f5046343c751b6d010468200/src/vs/base/common/map.ts#L434

Probably it has something to do with remote development, browser version or whatever.

ceribe commented 1 year ago

Sure thing, changed it.