Make sure we create a unique working copy resource for each custom editor resource

Fixes #106547

This switching the working copy resource for custom editors to use an encoded path instead of the resource's original path. This fixes a few problems:

- Fixes a bug where two resources with the same path (but different schemes or authorities) would be considered the same

- Fixes a bug where windows style paths (`c:\path`) would cause issues. This is the root cause of #106547

- Fixes a bug where the viewType was used as the raw authority. If the view type contains invalid characters, this would have caused issues
This commit is contained in:
Matt Bierner
2020-09-16 19:49:14 -07:00
parent 6f96936ee4
commit af5dd228ed

View File

@@ -346,10 +346,12 @@ class MainThreadCustomEditorModel extends Disposable implements ICustomEditorMod
}
private static toWorkingCopyResource(viewType: string, resource: URI) {
const authority = viewType.replace(/[^a-z0-9\-_]/gi, '-');
const path = '/' + btoa(resource.with({ query: null, fragment: null }).toString(true));
return URI.from({
scheme: Schemas.vscodeCustomEditor,
authority: viewType,
path: resource.path,
authority: authority,
path: path,
query: JSON.stringify(resource.toJSON()),
});
}