@@ -21,7 +21,8 @@ import { IWorkspaceContextService, Workspace, WorkbenchState } from 'vs/platform
2121import { WorkspaceService } from 'vs/workbench/services/configuration/node/configurationService' ;
2222import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors' ;
2323import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection' ;
24- import { realpath } from 'vs/base/node/pfs' ;
24+ import { stat } from 'vs/base/node/pfs' ;
25+ import { normalize , join , isAbsolute } from 'path' ;
2526import { EnvironmentService } from 'vs/platform/environment/node/environmentService' ;
2627import * as gracefulFs from 'graceful-fs' ;
2728import { KeyboardMapperFactory } from 'vs/workbench/services/keybinding/electron-browser/keybindingService' ;
@@ -147,30 +148,26 @@ function validateFolderUri(folderUri: ISingleFolderWorkspaceIdentifier, verbose:
147148 return TPromise . as ( folderUri ) ;
148149 }
149150
150- // Otherwise: use realpath to resolve symbolic links to the truth
151- return realpath ( folderUri . fsPath ) . then ( realFolderPath => {
151+ // Ensure absolute existing folder path
152+ let absoluteFolderPath = normalize ( isAbsolute ( folderUri . fsPath ) ? folderUri . fsPath : join ( process . env [ 'VSCODE_CWD' ] || process . cwd ( ) , folderUri . fsPath ) ) ;
153+ return stat ( absoluteFolderPath ) . then ( stat => {
152154
153155 // For some weird reason, node adds a trailing slash to UNC paths
154156 // we never ever want trailing slashes as our workspace path unless
155157 // someone opens root ("/").
156158 // See also https://github.com/nodejs/io.js/issues/1765
157- if ( paths . isUNC ( realFolderPath ) && strings . endsWith ( realFolderPath , paths . nativeSep ) ) {
158- realFolderPath = strings . rtrim ( realFolderPath , paths . nativeSep ) ;
159+ if ( paths . isUNC ( absoluteFolderPath ) && strings . endsWith ( absoluteFolderPath , paths . nativeSep ) ) {
160+ absoluteFolderPath = strings . rtrim ( absoluteFolderPath , paths . nativeSep ) ;
159161 }
160162
161- return uri . file ( realFolderPath ) ;
163+ return uri . file ( absoluteFolderPath ) ;
162164 } , error => {
163165 if ( verbose ) {
164166 errors . onUnexpectedError ( error ) ;
165167 }
166168
167169 // Treat any error case as empty workbench case (no folder path)
168170 return null ;
169-
170- } ) . then ( realFolderUriOrNull => {
171-
172- // Update config with real path if we have one
173- return realFolderUriOrNull ;
174171 } ) ;
175172}
176173
0 commit comments