@@ -163,13 +163,19 @@ define(function (require, exports, module) {
163163 let displayPath = ProjectManager . makeProjectRelativeIfPossible ( configFilePath ) ;
164164 displayPath = Phoenix . app . getDisplayPath ( displayPath ) ;
165165 DocumentManager . getDocumentForPath ( configFilePath ) . done ( function ( configDoc ) {
166+ if ( ! ProjectManager . isWithinProject ( configFilePath ) ) {
167+ // this is a rare race condition where the user switches project between the get document call.
168+ // Eg. in integ tests.
169+ reject ( `JSHint Project changed while scanning ${ configFilePath } ` ) ;
170+ return ;
171+ }
166172 let config ;
167173 const content = configDoc . getText ( ) ;
168174 try {
169175 config = JSON . parse ( removeComments ( content ) ) ;
170176 console . log ( "JSHint: loaded config file for project " + configFilePath ) ;
171177 } catch ( e ) {
172- console . log ( "JSHint: error parsing " + configFilePath ) ;
178+ console . log ( "JSHint: error parsing " + configFilePath , content , e ) ;
173179 // just log and return as this is an expected failure for us while the user edits code
174180 reject ( "Error parsing JSHint config file: " + displayPath ) ;
175181 return ;
@@ -209,11 +215,20 @@ define(function (require, exports, module) {
209215
210216 function _reloadOptions ( ) {
211217 projectSpecificOptions = null ;
212- _readConfig ( ProjectManager . getProjectRoot ( ) . fullPath , CONFIG_FILE_NAME ) . then ( ( config ) => {
218+ const scanningProjectPath = ProjectManager . getProjectRoot ( ) . fullPath ;
219+ _readConfig ( scanningProjectPath , CONFIG_FILE_NAME ) . then ( ( config ) => {
220+ if ( scanningProjectPath !== ProjectManager . getProjectRoot ( ) . fullPath ) {
221+ // this is a rare race condition where the user switches project between the get document call.
222+ // Eg. in integ tests. do nothing as another scan for the new project will be in progress.
223+ return ;
224+ }
213225 projectSpecificOptions = config ;
214226 CodeInspection . requestRun ( Strings . JSHINT_NAME ) ;
215227 jsHintConfigFileErrorMessage = null ;
216228 } ) . catch ( ( err ) => {
229+ if ( scanningProjectPath !== ProjectManager . getProjectRoot ( ) . fullPath ) {
230+ return ;
231+ }
217232 jsHintConfigFileErrorMessage = err ;
218233 CodeInspection . requestRun ( Strings . JSHINT_NAME ) ;
219234 } ) ;
0 commit comments