@@ -739,6 +739,7 @@ define(function (require, exports, module) {
739
739
entryType = isFolder ? Strings . DIRECTORY : Strings . FILE ,
740
740
title ,
741
741
message ;
742
+ path = Phoenix . app . getDisplayPath ( path ) ;
742
743
path = StringUtils . breakableUrl ( path ) ;
743
744
744
745
switch ( errType ) {
@@ -1312,7 +1313,9 @@ define(function (require, exports, module) {
1312
1313
// which is now partially torn down (see #6574).
1313
1314
model . projectRoot = null ;
1314
1315
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.
1316
1319
// Make sure not to reject the original deferred until the fallback
1317
1320
// project is loaded, so we don't violate expectations that there is always
1318
1321
// a current project before continuing after _loadProject().
@@ -1409,6 +1412,33 @@ define(function (require, exports, module) {
1409
1412
|| window . showOpenFilePicker ; // fs access file picker
1410
1413
}
1411
1414
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
+
1412
1442
/**
1413
1443
* Open a new project. Currently, Brackets must always have a project open, so
1414
1444
* this method handles both closing the current project and opening a new project.
@@ -1422,7 +1452,7 @@ define(function (require, exports, module) {
1422
1452
*/
1423
1453
function openProject ( path ) {
1424
1454
1425
- var result = new $ . Deferred ( ) ;
1455
+ const result = new $ . Deferred ( ) ;
1426
1456
1427
1457
if ( ! path && ! _filePickerSupported ( ) ) {
1428
1458
Dialogs . showModalDialog (
@@ -1434,29 +1464,24 @@ define(function (require, exports, module) {
1434
1464
return result . promise ( ) ;
1435
1465
}
1436
1466
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
+ } ) ;
1460
1485
1461
1486
// if fail, don't open new project: user canceled (or we failed to save its unsaved changes)
1462
1487
return result . promise ( ) ;
0 commit comments