@@ -301,6 +301,86 @@ define(function (require, exports, module) {
301301 _removePhoenixLoadingOverlay ( ) ;
302302 } ) ;
303303
304+ function _startupBrackets ( ) {
305+ // Load all extensions. This promise will complete even if one or more
306+ // extensions fail to load.
307+ const extensionPathOverride = params . get ( "extensions" ) ; // used by unit tests
308+ const extensionLoaderPromise = ExtensionLoader . init ( extensionPathOverride ? extensionPathOverride . split ( "," ) : null ) ;
309+
310+ // Finish UI initialization
311+ ViewCommandHandlers . restoreFontSize ( ) ;
312+ ProjectManager . getStartupProjectPath ( ) . then ( ( initialProjectPath ) => {
313+ ProjectManager . openProject ( initialProjectPath ) . always ( function ( ) {
314+ _initTest ( ) ;
315+
316+ // If this is the first launch, and we have an index.html file in the project folder (which should be
317+ // the samples folder on first launch), open it automatically. (We explicitly check for the
318+ // samples folder in case this is the first time we're launching Brackets after upgrading from
319+ // an old version that might not have set the "afterFirstLaunch" pref.)
320+ const deferred = new $ . Deferred ( ) ;
321+
322+ if ( ! params . get ( "skipSampleProjectLoad" ) && ! PreferencesManager . getViewState ( "afterFirstLaunch" ) ) {
323+ PreferencesManager . setViewState ( "afterFirstLaunch" , "true" ) ;
324+ if ( ProjectManager . isWelcomeProjectPath ( initialProjectPath ) ) {
325+ FileSystem . resolve ( initialProjectPath + "index.html" , function ( err , file ) {
326+ if ( ! err ) {
327+ const promise = CommandManager . execute ( Commands . CMD_ADD_TO_WORKINGSET_AND_OPEN , { fullPath : file . fullPath } ) ;
328+ promise . then ( deferred . resolve , deferred . reject ) ;
329+ } else {
330+ deferred . reject ( ) ;
331+ }
332+ } ) ;
333+ } else {
334+ deferred . resolve ( ) ;
335+ }
336+ } else {
337+ deferred . resolve ( ) ;
338+ }
339+
340+ deferred . always ( function ( ) {
341+ extensionLoaderPromise . always ( function ( ) {
342+ // Signal that extensions are loaded
343+ AppInit . _dispatchReady ( AppInit . EXTENSIONS_LOADED ) ;
344+ // Signal that Brackets is loaded
345+ AppInit . _dispatchReady ( AppInit . APP_READY ) ;
346+ _removePhoenixLoadingOverlay ( ) ;
347+
348+ PerfUtils . addMeasurement ( "Application Startup" ) ;
349+
350+ if ( PreferencesManager . _isUserScopeCorrupt ( ) ) {
351+ const userPrefFullPath = PreferencesManager . getUserPrefFile ( ) ;
352+ // user scope can get corrupt only if the file exists, is readable,
353+ // but malformed. no need to check for its existance.
354+ const info = MainViewManager . findInAllWorkingSets ( userPrefFullPath ) ;
355+ let paneId ;
356+ if ( info . length ) {
357+ paneId = info [ 0 ] . paneId ;
358+ }
359+ FileViewController . openFileAndAddToWorkingSet ( userPrefFullPath , paneId )
360+ . done ( function ( ) {
361+ Dialogs . showModalDialog (
362+ DefaultDialogs . DIALOG_ID_ERROR ,
363+ Strings . ERROR_PREFS_CORRUPT_TITLE ,
364+ Strings . ERROR_PREFS_CORRUPT
365+ ) . done ( function ( ) {
366+ // give the focus back to the editor with the pref file
367+ MainViewManager . focusActivePane ( ) ;
368+ } ) ;
369+ } ) ;
370+ }
371+ } ) ;
372+ } ) ;
373+
374+ // See if any startup files were passed to the application
375+ if ( brackets . app . getPendingFilesToOpen ) {
376+ brackets . app . getPendingFilesToOpen ( function ( err , paths ) {
377+ DragAndDrop . openDroppedFiles ( paths ) ;
378+ } ) ;
379+ }
380+ } ) ;
381+ } ) ;
382+ }
383+
304384 /**
305385 * Setup Brackets
306386 */
@@ -324,83 +404,11 @@ define(function (require, exports, module) {
324404
325405 // Load default languages and preferences
326406 Async . waitForAll ( [ LanguageManager . ready , PreferencesManager . ready ] ) . always ( function ( ) {
327- // Load all extensions. This promise will complete even if one or more
328- // extensions fail to load.
329- const extensionPathOverride = params . get ( "extensions" ) ; // used by unit tests
330- const extensionLoaderPromise = ExtensionLoader . init ( extensionPathOverride ? extensionPathOverride . split ( "," ) : null ) ;
331-
332- // Finish UI initialization
333- ViewCommandHandlers . restoreFontSize ( ) ;
334- ProjectManager . getStartupProjectPath ( ) . then ( ( initialProjectPath ) => {
335- ProjectManager . openProject ( initialProjectPath ) . always ( function ( ) {
336- _initTest ( ) ;
337-
338- // If this is the first launch, and we have an index.html file in the project folder (which should be
339- // the samples folder on first launch), open it automatically. (We explicitly check for the
340- // samples folder in case this is the first time we're launching Brackets after upgrading from
341- // an old version that might not have set the "afterFirstLaunch" pref.)
342- const deferred = new $ . Deferred ( ) ;
343-
344- if ( ! params . get ( "skipSampleProjectLoad" ) && ! PreferencesManager . getViewState ( "afterFirstLaunch" ) ) {
345- PreferencesManager . setViewState ( "afterFirstLaunch" , "true" ) ;
346- if ( ProjectManager . isWelcomeProjectPath ( initialProjectPath ) ) {
347- FileSystem . resolve ( initialProjectPath + "index.html" , function ( err , file ) {
348- if ( ! err ) {
349- const promise = CommandManager . execute ( Commands . CMD_ADD_TO_WORKINGSET_AND_OPEN , { fullPath : file . fullPath } ) ;
350- promise . then ( deferred . resolve , deferred . reject ) ;
351- } else {
352- deferred . reject ( ) ;
353- }
354- } ) ;
355- } else {
356- deferred . resolve ( ) ;
357- }
358- } else {
359- deferred . resolve ( ) ;
360- }
361-
362- deferred . always ( function ( ) {
363- extensionLoaderPromise . always ( function ( ) {
364- // Signal that extensions are loaded
365- AppInit . _dispatchReady ( AppInit . EXTENSIONS_LOADED ) ;
366- // Signal that Brackets is loaded
367- AppInit . _dispatchReady ( AppInit . APP_READY ) ;
368- _removePhoenixLoadingOverlay ( ) ;
369-
370- PerfUtils . addMeasurement ( "Application Startup" ) ;
371-
372- if ( PreferencesManager . _isUserScopeCorrupt ( ) ) {
373- const userPrefFullPath = PreferencesManager . getUserPrefFile ( ) ;
374- // user scope can get corrupt only if the file exists, is readable,
375- // but malformed. no need to check for its existance.
376- const info = MainViewManager . findInAllWorkingSets ( userPrefFullPath ) ;
377- let paneId ;
378- if ( info . length ) {
379- paneId = info [ 0 ] . paneId ;
380- }
381- FileViewController . openFileAndAddToWorkingSet ( userPrefFullPath , paneId )
382- . done ( function ( ) {
383- Dialogs . showModalDialog (
384- DefaultDialogs . DIALOG_ID_ERROR ,
385- Strings . ERROR_PREFS_CORRUPT_TITLE ,
386- Strings . ERROR_PREFS_CORRUPT
387- ) . done ( function ( ) {
388- // give the focus back to the editor with the pref file
389- MainViewManager . focusActivePane ( ) ;
390- } ) ;
391- } ) ;
392- }
393- } ) ;
394- } ) ;
395-
396- // See if any startup files were passed to the application
397- if ( brackets . app . getPendingFilesToOpen ) {
398- brackets . app . getPendingFilesToOpen ( function ( err , paths ) {
399- DragAndDrop . openDroppedFiles ( paths ) ;
400- } ) ;
401- }
402- } ) ;
403- } ) ;
407+ if ( window . _phoenixfsAppDirsCreatePromise ) {
408+ window . _phoenixfsAppDirsCreatePromise . finally ( _startupBrackets ) ;
409+ } else {
410+ _startupBrackets ( ) ;
411+ }
404412 } ) ;
405413 }
406414
0 commit comments