@@ -738,7 +738,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
738738 }
739739
740740 if ( editor . resource ) {
741- return this . editorsObserver . hasEditor ( editor . resource ) ;
741+ return this . editorsObserver . hasEditor ( this . asCanonicalEditorResource ( editor . resource ) ) ;
742742 }
743743
744744 return false ;
@@ -872,25 +872,14 @@ export class EditorService extends Disposable implements EditorServiceImpl {
872872 const resourceEditorInput = input as IResourceEditorInput ;
873873 if ( resourceEditorInput . resource instanceof URI ) {
874874
875- // Before creating an editor input for the given URI, we prefer
876- // to use the canonical form of it unless we know that a model
877- // for the given URI already exists.
878- // If no model exists, we do not trust the resource that is being
879- // passed in as being the truth (e.g. in terms of path casing) and
880- // as such we ask the URI service to give us the canconical form of
881- // the URI. As such we ensure that any editor that is being opened
882- // will use the same canonical form of the URI.
883- let canonicalResource : URI ;
884- if ( this . modelService . getModel ( resourceEditorInput . resource ) ) {
885- // TODO@Ben remove this check once canonical URIs are adopted in ITextModelResolerService
886- canonicalResource = resourceEditorInput . resource ;
887- } else {
888- canonicalResource = this . uriIdentityService . asCanonicalUri ( resourceEditorInput . resource ) ;
889- }
890-
891875 // Derive the label from the path if not provided explicitly
892876 const label = resourceEditorInput . label || basename ( resourceEditorInput . resource ) ;
893877
878+ // From this moment on, only operate on the canonical resource
879+ // to ensure we reduce the chance of opening the same resource
880+ // with different resource forms (e.g. path casing on Windows)
881+ const canonicalResource = this . asCanonicalEditorResource ( resourceEditorInput . resource ) ;
882+
894883 return this . createOrGetCached ( canonicalResource , ( ) => {
895884
896885 // File
@@ -938,6 +927,25 @@ export class EditorService extends Disposable implements EditorServiceImpl {
938927 throw new Error ( 'Unknown input type' ) ;
939928 }
940929
930+ private asCanonicalEditorResource ( resource : URI ) : URI {
931+ // We prefer to use the canonical form unless we know that a model
932+ // for the given URI already exists.
933+ // If no model exists, we do not trust the resource that is being
934+ // passed in as being the truth (e.g. in terms of path casing) and
935+ // as such we ask the URI service to give us the canconical form of
936+ // the URI. As such we ensure that any editor that is being opened
937+ // will use the same canonical form of the URI.
938+ let canonicalResource : URI ;
939+ if ( this . modelService . getModel ( resource ) ) {
940+ // TODO@Ben remove this check once canonical URIs are adopted in ITextModelResolerService
941+ canonicalResource = resource ;
942+ } else {
943+ canonicalResource = this . uriIdentityService . asCanonicalUri ( resource ) ;
944+ }
945+
946+ return canonicalResource ;
947+ }
948+
941949 private createOrGetCached ( resource : URI , factoryFn : ( ) => CachedEditorInput , cachedFn ?: ( input : CachedEditorInput ) => void ) : CachedEditorInput {
942950
943951 // Return early if already cached
0 commit comments