Skip to content

Commit aa013aa

Browse files
author
Benjamin Pasero
committed
editors - cleanup canonical todo
1 parent c5c319e commit aa013aa

2 files changed

Lines changed: 8 additions & 20 deletions

File tree

src/vs/workbench/contrib/files/common/editors/fileEditorInput.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,6 @@ export class FileEditorInput extends AbstractTextResourceEditorInput implements
8686

8787
// Once the text file model is created, we keep it inside
8888
// the input to be able to implement some methods properly
89-
// TODO@ben once we are certain that models will only be
90-
// created with canonical URIs, this should use the URI
91-
// identity service. But as long as there is a chance
92-
// that a model is created with same path but different
93-
// case, we can only accept that model here if the URIs
94-
// are 100% identical.
9589
if (extUri.isEqual(model.resource, this.resource)) {
9690
this.model = model;
9791

src/vs/workbench/services/editor/browser/editorService.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IFileService, FileOperationEvent, FileOperation, FileChangesEvent, File
1515
import { Schemas } from 'vs/base/common/network';
1616
import { Event, Emitter } from 'vs/base/common/event';
1717
import { URI } from 'vs/base/common/uri';
18-
import { basename, joinPath } from 'vs/base/common/resources';
18+
import { basename, joinPath, extUri } from 'vs/base/common/resources';
1919
import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
2020
import { IEditorGroupsService, IEditorGroup, GroupsOrder, IEditorReplacement, GroupChangeKind, preferredSideBySideGroupDirection, OpenEditorContext } from 'vs/workbench/services/editor/common/editorGroupsService';
2121
import { IResourceEditorInputType, SIDE_GROUP, IResourceEditorReplacement, IOpenEditorOverrideHandler, IEditorService, SIDE_GROUP_TYPE, ACTIVE_GROUP_TYPE, ISaveEditorsOptions, ISaveAllEditorsOptions, IRevertAllEditorsOptions, IBaseSaveRevertAllEditorOptions, IOpenEditorOverrideEntry, ICustomEditorViewTypesHandler, ICustomEditorInfo } from 'vs/workbench/services/editor/common/editorService';
@@ -938,19 +938,13 @@ export class EditorService extends Disposable implements EditorServiceImpl {
938938
}
939939

940940
private asCanonicalEditorResource(resource: URI): URI {
941-
// We prefer to use the canonical form unless we know that a model
942-
// for the given URI already exists.
943-
// If no model exists, we do not trust the resource that is being
944-
// passed in as being the truth (e.g. in terms of path casing) and
945-
// as such we ask the URI service to give us the canconical form of
946-
// the URI. As such we ensure that any editor that is being opened
947-
// will use the same canonical form of the URI.
948-
let canonicalResource: URI;
949-
if (this.modelService?.getModel(resource)) {
950-
// TODO@Ben remove this check once canonical URIs are adopted in ITextModelResolerService
951-
canonicalResource = resource;
952-
} else {
953-
canonicalResource = this.uriIdentityService.asCanonicalUri(resource);
941+
const canonicalResource: URI = this.uriIdentityService.asCanonicalUri(resource);
942+
943+
// In the unlikely case that a model exists for the original resource but
944+
// differs from the canonical resource, we print a warning as this means
945+
// the model will not be able to be opened as editor.
946+
if (!extUri.isEqual(resource, canonicalResource) && this.modelService?.getModel(resource)) {
947+
console.warn(`EditorService: a model exists for a resource that is not canonical: ${resource.toString(true)}`);
954948
}
955949

956950
return canonicalResource;

0 commit comments

Comments
 (0)