Skip to content

Commit

Permalink
Make sure we create a unique working copy resource for each custom ed…
Browse files Browse the repository at this point in the history
…itor 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
  • Loading branch information
mjbvz committed Sep 17, 2020
1 parent 6f96936 commit af5dd22
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/vs/workbench/api/browser/mainThreadCustomEditors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
});
}
Expand Down

0 comments on commit af5dd22

Please sign in to comment.