@@ -674,57 +674,61 @@ define(function LiveDevelopment(require, exports, module) {
674
674
hasOwnServerForLiveDevelopment = ( baseUrl && baseUrl . length ) ;
675
675
676
676
FileIndexManager . getFileInfoList ( "all" ) . done ( function ( allFiles ) {
677
+ var projectRoot = ProjectManager . getProjectRoot ( ) . fullPath ,
678
+ containingFolder ,
679
+ indexFileFound = false ,
680
+ stillInProjectTree = true ;
681
+
677
682
if ( refPath ) {
678
- var projectRoot = ProjectManager . getProjectRoot ( ) . fullPath ,
679
- containingFolder = FileUtils . getDirectoryPath ( refPath ) ,
680
- indexFileFound = false ,
681
- stillInProjectTree = true ;
682
-
683
- var filteredFiltered = allFiles . filter ( function ( item ) {
684
- var parent = getParentFolder ( item . fullPath ) ;
685
-
686
- return ( containingFolder . indexOf ( parent ) === 0 ) ;
687
- } ) ;
683
+ containingFolder = FileUtils . getDirectoryPath ( refPath ) ;
684
+ } else {
685
+ containingFolder = projectRoot ;
686
+ }
687
+
688
+ var filteredFiltered = allFiles . filter ( function ( item ) {
689
+ var parent = getParentFolder ( item . fullPath ) ;
688
690
689
- var filterIndexFile = function ( fileInfo ) {
690
- if ( fileInfo . fullPath . indexOf ( containingFolder ) === 0 ) {
691
- if ( getFilenameWithoutExtension ( fileInfo . name ) === "index" ) {
692
- if ( hasOwnServerForLiveDevelopment ) {
693
- if ( ( FileUtils . isServerHtmlFileExt ( fileInfo . name ) ) ||
694
- ( FileUtils . isStaticHtmlFileExt ( fileInfo . name ) ) ) {
695
- return true ;
696
- }
697
- } else if ( FileUtils . isStaticHtmlFileExt ( fileInfo . name ) ) {
691
+ return ( containingFolder . indexOf ( parent ) === 0 ) ;
692
+ } ) ;
693
+
694
+ var filterIndexFile = function ( fileInfo ) {
695
+ if ( fileInfo . fullPath . indexOf ( containingFolder ) === 0 ) {
696
+ if ( getFilenameWithoutExtension ( fileInfo . name ) === "index" ) {
697
+ if ( hasOwnServerForLiveDevelopment ) {
698
+ if ( ( FileUtils . isServerHtmlFileExt ( fileInfo . name ) ) ||
699
+ ( FileUtils . isStaticHtmlFileExt ( fileInfo . name ) ) ) {
698
700
return true ;
699
701
}
700
- } else {
701
- return false ;
702
- }
703
- }
704
- } ;
705
-
706
- while ( ! indexFileFound && stillInProjectTree ) {
707
- i = CollectionUtils . indexOf ( filteredFiltered , filterIndexFile ) ;
708
-
709
- // We found no good match
710
- if ( i === - 1 ) {
711
- // traverse the directory tree up one level
712
- containingFolder = getParentFolder ( containingFolder ) ;
713
- // Are we still inside the project?
714
- if ( containingFolder . indexOf ( projectRoot ) === - 1 ) {
715
- stillInProjectTree = false ;
702
+ } else if ( FileUtils . isStaticHtmlFileExt ( fileInfo . name ) ) {
703
+ return true ;
716
704
}
717
705
} else {
718
- indexFileFound = true ;
706
+ return false ;
719
707
}
720
708
}
721
-
722
- if ( i !== - 1 ) {
723
- DocumentManager . getDocumentForPath ( filteredFiltered [ i ] . fullPath ) . then ( result . resolve , result . resolve ) ;
724
- return ;
709
+ } ;
710
+
711
+ while ( ! indexFileFound && stillInProjectTree ) {
712
+ i = CollectionUtils . indexOf ( filteredFiltered , filterIndexFile ) ;
713
+
714
+ // We found no good match
715
+ if ( i === - 1 ) {
716
+ // traverse the directory tree up one level
717
+ containingFolder = getParentFolder ( containingFolder ) ;
718
+ // Are we still inside the project?
719
+ if ( containingFolder . indexOf ( projectRoot ) === - 1 ) {
720
+ stillInProjectTree = false ;
721
+ }
722
+ } else {
723
+ indexFileFound = true ;
725
724
}
726
725
}
727
726
727
+ if ( i !== - 1 ) {
728
+ DocumentManager . getDocumentForPath ( filteredFiltered [ i ] . fullPath ) . then ( result . resolve , result . resolve ) ;
729
+ return ;
730
+ }
731
+
728
732
result . resolve ( null ) ;
729
733
} ) ;
730
734
@@ -1163,10 +1167,16 @@ define(function LiveDevelopment(require, exports, module) {
1163
1167
// TODO: need to run _onDocumentChange() after load if doc != currentDocument here? Maybe not, since activeEditorChange
1164
1168
// doesn't trigger it, while inline editors can still cause edits in doc other than currentDoc...
1165
1169
_getInitialDocFromCurrent ( ) . done ( function ( doc ) {
1166
- var prepareServerPromise = ( doc && _prepareServer ( doc ) ) || new $ . Deferred ( ) . reject ( ) ;
1170
+ var prepareServerPromise = ( doc && _prepareServer ( doc ) ) || new $ . Deferred ( ) . reject ( ) ,
1171
+ otherDocumentsInWorkingFiles ;
1167
1172
1168
1173
if ( doc && ! doc . _masterEditor ) {
1174
+ otherDocumentsInWorkingFiles = DocumentManager . getWorkingSet ( ) . length ;
1169
1175
DocumentManager . addToWorkingSet ( doc . file ) ;
1176
+
1177
+ if ( ! otherDocumentsInWorkingFiles ) {
1178
+ DocumentManager . setCurrentDocument ( doc ) ;
1179
+ }
1170
1180
}
1171
1181
1172
1182
// wait for server (StaticServer, Base URL or file:)
0 commit comments