Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(data-explorer): opening documents with _ids with slashes VSCODE-276 #342

Merged
merged 4 commits into from
Oct 19, 2021

Conversation

Anemy
Copy link
Member

@Anemy Anemy commented Aug 31, 2021

VSCODE-276

We were opening documents with the virtual file name with a slash in it which made VSCode think it was in a folder and couldn't find it. This PR updates it so that now we trim these special characters from the file name before displaying them.

Also added a playground useful for seeding a db with some docs with different kinds of _ids.

Addresses #284

open.different._ids.mp4

@Anemy Anemy changed the title fix(data-explorer): opening _ids with slashes in them VSCODE-276 fix(data-explorer): opening documents with _ids with slashes VSCODE-276 Aug 31, 2021
@Anemy Anemy requested a review from alenakhineika September 23, 2021 14:37
@Anemy Anemy requested review from alenakhineika and removed request for alenakhineika October 13, 2021 02:08
Comment on lines 40 to 41
const regularExpression = /[\\\/]/gi;
displayName = displayName.replace(regularExpression, '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a dumb question, is it important that these are unique, i.e. is it a problem to match a/b and ab to the same display name? If so, maybe encodeURIComponent() makes sense here?

Copy link
Member Author

@Anemy Anemy Oct 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that would be a better way to do it, good thinking. I'll update. Looks like that collision would have caused an error saying you can't change _id which would be nice to avoid.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@addaleax Updated it to encode these characters. Also started encoding the namespace since it's possible to have some special characters in a collection name.
Screen Shot 2021-10-19 at 8 13 06 AM

Open and editing this document works so I think we're good? The display name can be less nice looking with a lot of those characters, but I think it makes sense and works as expected. We're not encoding everything here because vscode uses the file name as the file title and we want the file name to look as close to the data as possible (it will decode and try to parse the /). I'll add a note to mention in docs that we're encoding special characters here so the display name might not quite match the _id value.
Screen Shot 2021-10-19 at 8 45 09 AM

Copy link
Contributor

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@Anemy Anemy merged commit 1c09841 into main Oct 19, 2021
@Anemy Anemy deleted the VSCODE-276 branch October 19, 2021 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants