@@ -17,7 +17,7 @@ import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
17
17
import { Schemas } from 'vs/base/common/network' ;
18
18
import { basename , join , normalize , posix } from 'vs/base/common/path' ;
19
19
import { getMarks , mark } from 'vs/base/common/performance' ;
20
- import { IProcessEnvironment , isMacintosh } from 'vs/base/common/platform' ;
20
+ import { IProcessEnvironment , isMacintosh , isWindows } from 'vs/base/common/platform' ;
21
21
import { cwd } from 'vs/base/common/process' ;
22
22
import { extUriBiasedIgnorePathCase , normalizePath , originalFSPath , removeTrailingPathSeparator } from 'vs/base/common/resources' ;
23
23
import { equalsIgnoreCase } from 'vs/base/common/strings' ;
@@ -974,6 +974,8 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
974
974
975
975
try {
976
976
const pathStat = statSync ( path ) ;
977
+
978
+ // File
977
979
if ( pathStat . isFile ( ) ) {
978
980
979
981
// Workspace (unless disabled via flag)
@@ -991,19 +993,30 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
991
993
}
992
994
}
993
995
994
- // File
995
996
return {
996
997
fileUri : URI . file ( path ) ,
997
998
selection : lineNumber ? { startLineNumber : lineNumber , startColumn : columnNumber || 1 } : undefined ,
998
999
exists : true
999
1000
} ;
1000
1001
}
1001
1002
1002
- // Folder (we check for isDirectory() because e.g. paths like /dev/null
1003
- // are neither file nor folder but some external tools might pass them
1004
- // over to us)
1003
+ // Folder
1005
1004
else if ( pathStat . isDirectory ( ) ) {
1006
- return { workspace : getSingleFolderWorkspaceIdentifier ( URI . file ( path ) , pathStat ) , exists : true } ;
1005
+ return {
1006
+ workspace : getSingleFolderWorkspaceIdentifier ( URI . file ( path ) , pathStat ) ,
1007
+ exists : true
1008
+ } ;
1009
+ }
1010
+
1011
+ // Special device: in POSIX environments, we may get /dev/null passed
1012
+ // in (for example git uses it to signal one side of a diff does not
1013
+ // exist). In that special case, treat it like a file to support this
1014
+ // scenario ()
1015
+ else if ( ! isWindows && path === '/dev/null' ) {
1016
+ return {
1017
+ fileUri : URI . file ( path ) ,
1018
+ exists : true
1019
+ } ;
1007
1020
}
1008
1021
} catch ( error ) {
1009
1022
const fileUri = URI . file ( path ) ;
@@ -1013,7 +1026,10 @@ export class WindowsMainService extends Disposable implements IWindowsMainServic
1013
1026
1014
1027
// assume this is a file that does not yet exist
1015
1028
if ( options . ignoreFileNotFound ) {
1016
- return { fileUri, exists : false } ;
1029
+ return {
1030
+ fileUri,
1031
+ exists : false
1032
+ } ;
1017
1033
}
1018
1034
}
1019
1035
0 commit comments