@@ -385,22 +385,7 @@ export class ExtensionCommandsFeature implements IFeature {
385
385
private closeFile ( filePath : string ) : Thenable < EditorOperationResponse > {
386
386
387
387
var promise : Thenable < EditorOperationResponse > ;
388
-
389
- var normalizedFilePath = this . normalizeFilePath ( filePath ) ;
390
-
391
- // since Windows is case-insensitive, we need to normalize it differently
392
- var canFind = vscode . workspace . textDocuments . find ( doc => {
393
- var docPath , platform = os . platform ( ) ;
394
- if ( platform == "win32" || platform == "darwin" ) {
395
- // for windows paths, they are normalized to be lowercase
396
- docPath = doc . fileName . toLowerCase ( ) ;
397
- } else {
398
- docPath = doc . fileName ;
399
- }
400
- return docPath == normalizedFilePath ;
401
- } ) ;
402
-
403
- if ( canFind )
388
+ if ( this . findTextDocument ( this . normalizeFilePath ( filePath ) ) )
404
389
{
405
390
promise =
406
391
vscode . workspace . openTextDocument ( filePath )
@@ -419,22 +404,7 @@ export class ExtensionCommandsFeature implements IFeature {
419
404
private saveFile ( filePath : string ) : Thenable < EditorOperationResponse > {
420
405
421
406
var promise : Thenable < EditorOperationResponse > ;
422
-
423
- var normalizedFilePath = this . normalizeFilePath ( filePath ) ;
424
-
425
- // since Windows is case-insensitive, we need to normalize it differently
426
- var canFind = vscode . workspace . textDocuments . find ( doc => {
427
- var docPath , platform = os . platform ( ) ;
428
- if ( platform == "win32" || platform == "darwin" ) {
429
- // for windows paths, they are normalized to be lowercase
430
- docPath = doc . fileName . toLowerCase ( ) ;
431
- } else {
432
- docPath = doc . fileName ;
433
- }
434
- return docPath == normalizedFilePath ;
435
- } ) ;
436
-
437
- if ( canFind )
407
+ if ( this . findTextDocument ( this . normalizeFilePath ( filePath ) ) )
438
408
{
439
409
promise =
440
410
vscode . workspace . openTextDocument ( filePath )
@@ -484,6 +454,22 @@ export class ExtensionCommandsFeature implements IFeature {
484
454
}
485
455
}
486
456
457
+ private findTextDocument ( filePath : string ) : boolean {
458
+ // since Windows and macOS are case-insensitive, we need to normalize them differently
459
+ var canFind = vscode . workspace . textDocuments . find ( doc => {
460
+ var docPath , platform = os . platform ( ) ;
461
+ if ( platform == "win32" || platform == "darwin" ) {
462
+ // for Windows and macOS paths, they are normalized to be lowercase
463
+ docPath = doc . fileName . toLowerCase ( ) ;
464
+ } else {
465
+ docPath = doc . fileName ;
466
+ }
467
+ return docPath == filePath ;
468
+ } ) ;
469
+
470
+ return canFind != null ;
471
+ }
472
+
487
473
private setSelection ( details : SetSelectionRequestArguments ) : EditorOperationResponse {
488
474
vscode . window . activeTextEditor . selections = [
489
475
new vscode . Selection (
0 commit comments