@@ -18,6 +18,7 @@ import { IRazorDocumentManager } from './IRazorDocumentManager';
18
18
import { RazorDocumentChangeKind } from './razorDocumentChangeKind' ;
19
19
import { createDocument } from './razorDocumentFactory' ;
20
20
import { razorInitializeCommand } from '../../../lsptoolshost/razorCommands' ;
21
+ import { PlatformInformation } from '../../../shared/platform' ;
21
22
22
23
export class RazorDocumentManager implements IRazorDocumentManager {
23
24
public roslynActivated = false ;
@@ -32,7 +33,8 @@ export class RazorDocumentManager implements IRazorDocumentManager {
32
33
constructor (
33
34
private readonly serverClient : RazorLanguageServerClient ,
34
35
private readonly logger : RazorLogger ,
35
- private readonly telemetryReporter : TelemetryReporter
36
+ private readonly telemetryReporter : TelemetryReporter ,
37
+ private readonly platformInfo : PlatformInformation
36
38
) { }
37
39
38
40
public get onChange ( ) {
@@ -146,7 +148,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
146
148
147
149
private _getDocument ( uri : vscode . Uri ) {
148
150
const path = getUriPath ( uri ) ;
149
- let document = this . razorDocuments [ path ] ;
151
+ let document = this . findDocument ( path ) ;
150
152
151
153
// This might happen in the case that a file is opened outside the workspace
152
154
if ( ! document ) {
@@ -198,7 +200,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
198
200
199
201
private addDocument ( uri : vscode . Uri ) {
200
202
const path = getUriPath ( uri ) ;
201
- let document = this . razorDocuments [ path ] ;
203
+ let document = this . findDocument ( path ) ;
202
204
if ( document ) {
203
205
this . logger . logMessage ( `Skipping document creation for '${ path } ' because it already exists.` ) ;
204
206
return document ;
@@ -219,6 +221,26 @@ export class RazorDocumentManager implements IRazorDocumentManager {
219
221
this . notifyDocumentChange ( document , RazorDocumentChangeKind . removed ) ;
220
222
}
221
223
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
+
222
244
private async updateCSharpBuffer ( updateBufferRequest : UpdateBufferRequest ) {
223
245
if ( this . logger . verboseEnabled ) {
224
246
this . logger . logVerbose (
0 commit comments