@@ -739,6 +739,7 @@ define(function (require, exports, module) {
739739 entryType = isFolder ? Strings . DIRECTORY : Strings . FILE ,
740740 title ,
741741 message ;
742+ path = Phoenix . app . getDisplayPath ( path ) ;
742743 path = StringUtils . breakableUrl ( path ) ;
743744
744745 switch ( errType ) {
@@ -1312,7 +1313,9 @@ define(function (require, exports, module) {
13121313 // which is now partially torn down (see #6574).
13131314 model . projectRoot = null ;
13141315
1315- _loadProject ( getWelcomeProjectPath ( ) ) . always ( function ( ) {
1316+ _loadProject ( getPlaceholderProjectPath ( ) ) . always ( function ( ) {
1317+ // we dont load any other project here as the saved project state will not get restored
1318+ // if we load an actual project at this time.
13161319 // Make sure not to reject the original deferred until the fallback
13171320 // project is loaded, so we don't violate expectations that there is always
13181321 // a current project before continuing after _loadProject().
@@ -1409,6 +1412,33 @@ define(function (require, exports, module) {
14091412 || window . showOpenFilePicker ; // fs access file picker
14101413 }
14111414
1415+ function _openProject ( path , result ) {
1416+ // Confirm any unsaved changes first. We run the command in "prompt-only" mode, meaning it won't
1417+ // actually close any documents even on success; we'll do that manually after the user also oks
1418+ // the folder-browse dialog.
1419+ CommandManager . execute ( Commands . FILE_CLOSE_ALL , { promptOnly : true } )
1420+ . done ( function ( ) {
1421+ if ( path ) {
1422+ // use specified path
1423+ _loadProject ( path ) . then ( result . resolve , result . reject ) ;
1424+ } else {
1425+ // Pop up a folder browse dialog
1426+ FileSystem . showOpenDialog ( false , true , Strings . CHOOSE_FOLDER , model . projectRoot . fullPath , null ,
1427+ function ( err , files ) {
1428+ if ( ! err && files . length > 0 ) {
1429+ // Load the new project into the folder tree
1430+ _loadProject ( files [ 0 ] ) . then ( result . resolve , result . reject ) ;
1431+ } else {
1432+ result . reject ( ) ;
1433+ }
1434+ } ) ;
1435+ }
1436+ } )
1437+ . fail ( function ( ) {
1438+ result . reject ( ) ;
1439+ } ) ;
1440+ }
1441+
14121442 /**
14131443 * Open a new project. Currently, Brackets must always have a project open, so
14141444 * this method handles both closing the current project and opening a new project.
@@ -1422,7 +1452,7 @@ define(function (require, exports, module) {
14221452 */
14231453 function openProject ( path ) {
14241454
1425- var result = new $ . Deferred ( ) ;
1455+ const result = new $ . Deferred ( ) ;
14261456
14271457 if ( ! path && ! _filePickerSupported ( ) ) {
14281458 Dialogs . showModalDialog (
@@ -1434,29 +1464,24 @@ define(function (require, exports, module) {
14341464 return result . promise ( ) ;
14351465 }
14361466
1437- // Confirm any unsaved changes first. We run the command in "prompt-only" mode, meaning it won't
1438- // actually close any documents even on success; we'll do that manually after the user also oks
1439- // the folder-browse dialog.
1440- CommandManager . execute ( Commands . FILE_CLOSE_ALL , { promptOnly : true } )
1441- . done ( function ( ) {
1442- if ( path ) {
1443- // use specified path
1444- _loadProject ( path ) . then ( result . resolve , result . reject ) ;
1445- } else {
1446- // Pop up a folder browse dialog
1447- FileSystem . showOpenDialog ( false , true , Strings . CHOOSE_FOLDER , model . projectRoot . fullPath , null , function ( err , files ) {
1448- if ( ! err && files . length > 0 ) {
1449- // Load the new project into the folder tree
1450- _loadProject ( files [ 0 ] ) . then ( result . resolve , result . reject ) ;
1451- } else {
1452- result . reject ( ) ;
1453- }
1454- } ) ;
1455- }
1456- } )
1457- . fail ( function ( ) {
1458- result . reject ( ) ;
1459- } ) ;
1467+ if ( ! path ) {
1468+ _openProject ( null , result ) ;
1469+ return result . promise ( ) ;
1470+ }
1471+
1472+ const rootEntry = FileSystem . getDirectoryForPath ( path ) ;
1473+ rootEntry . exists ( function ( err , exists ) {
1474+ if ( exists ) {
1475+ _openProject ( path , result ) ;
1476+ return ;
1477+ }
1478+ console . error ( "error project open path doesnt exist: " , path , err ) ;
1479+ exports . trigger ( EVENT_PROJECT_OPEN_FAILED , path ) ;
1480+ _showErrorDialog ( ERR_TYPE_LOADING_PROJECT_NATIVE , true , FileSystemError . NOT_FOUND , path )
1481+ . done ( function ( ) {
1482+ result . reject ( ) ;
1483+ } ) ;
1484+ } ) ;
14601485
14611486 // if fail, don't open new project: user canceled (or we failed to save its unsaved changes)
14621487 return result . promise ( ) ;
0 commit comments