@@ -18,6 +18,7 @@ import { IRazorDocumentManager } from './IRazorDocumentManager';
1818import { RazorDocumentChangeKind } from './razorDocumentChangeKind' ;
1919import { createDocument } from './razorDocumentFactory' ;
2020import { razorInitializeCommand } from '../../../lsptoolshost/razorCommands' ;
21+ import { PlatformInformation } from '../../../shared/platform' ;
2122
2223export class RazorDocumentManager implements IRazorDocumentManager {
2324 public roslynActivated = false ;
@@ -32,7 +33,8 @@ export class RazorDocumentManager implements IRazorDocumentManager {
3233 constructor (
3334 private readonly serverClient : RazorLanguageServerClient ,
3435 private readonly logger : RazorLogger ,
35- private readonly telemetryReporter : TelemetryReporter
36+ private readonly telemetryReporter : TelemetryReporter ,
37+ private readonly platformInfo : PlatformInformation
3638 ) { }
3739
3840 public get onChange ( ) {
@@ -146,7 +148,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
146148
147149 private _getDocument ( uri : vscode . Uri ) {
148150 const path = getUriPath ( uri ) ;
149- let document = this . razorDocuments [ path ] ;
151+ let document = this . findDocument ( path ) ;
150152
151153 // This might happen in the case that a file is opened outside the workspace
152154 if ( ! document ) {
@@ -198,7 +200,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
198200
199201 private addDocument ( uri : vscode . Uri ) {
200202 const path = getUriPath ( uri ) ;
201- let document = this . razorDocuments [ path ] ;
203+ let document = this . findDocument ( path ) ;
202204 if ( document ) {
203205 this . logger . logMessage ( `Skipping document creation for '${ path } ' because it already exists.` ) ;
204206 return document ;
@@ -219,6 +221,26 @@ export class RazorDocumentManager implements IRazorDocumentManager {
219221 this . notifyDocumentChange ( document , RazorDocumentChangeKind . removed ) ;
220222 }
221223
224+ private findDocument ( path : string ) {
225+ // This method ultimately gets called from VS Code, using file system paths, or from DevKit, which
226+ // can use paths as specified in the sln file. When these don't agree, on case-insensitive operating
227+ // systems, we have to be careful to match things up correctly.
228+
229+ if ( this . platformInfo . isLinux ( ) ) {
230+ return this . razorDocuments [ path ] ;
231+ }
232+
233+ const lowerCasePath = path . toLowerCase ( ) ;
234+ const key = Object . keys ( this . razorDocuments ) . find (
235+ ( documentPath ) => documentPath . toLowerCase ( ) === lowerCasePath
236+ ) ;
237+ if ( key ) {
238+ return this . razorDocuments [ key ] ;
239+ }
240+
241+ return undefined ;
242+ }
243+
222244 private async updateCSharpBuffer ( updateBufferRequest : UpdateBufferRequest ) {
223245 if ( this . logger . verboseEnabled ) {
224246 this . logger . logVerbose (
0 commit comments