@@ -318,17 +318,20 @@ protected async Task HandleDidChangeConfigurationNotification(
318
318
}
319
319
320
320
// If there is a new settings file path, restart the analyzer with the new settigs.
321
+ bool settingsPathChanged = false ;
321
322
string newSettingsPath = this . currentSettings . ScriptAnalysis . SettingsPath ;
322
323
if ( ! ( oldScriptAnalysisSettingsPath ? . Equals ( newSettingsPath , StringComparison . OrdinalIgnoreCase ) ?? false ) )
323
324
{
324
325
this . editorSession . RestartAnalysisService ( newSettingsPath ) ;
326
+ settingsPathChanged = true ;
325
327
}
326
328
327
- if ( oldScriptAnalysisEnabled != this . currentSettings . ScriptAnalysis . Enable )
329
+ // If script analysis settings have changed we need to clear & possibly update the current diagnostic records.
330
+ if ( ( oldScriptAnalysisEnabled != this . currentSettings . ScriptAnalysis . Enable ) || settingsPathChanged )
328
331
{
329
- // If the user just turned off script analysis, send a diagnostics
330
- // event to clear the analysis markers that they already have
331
- if ( ! this . currentSettings . ScriptAnalysis . Enable . Value )
332
+ // If the user just turned off script analysis or changed the settings path , send a diagnostics
333
+ // event to clear the analysis markers that they already have.
334
+ if ( ! this . currentSettings . ScriptAnalysis . Enable . Value || settingsPathChanged )
332
335
{
333
336
ScriptFileMarker [ ] emptyAnalysisDiagnostics = new ScriptFileMarker [ 0 ] ;
334
337
@@ -340,6 +343,15 @@ await PublishScriptDiagnostics(
340
343
eventContext ) ;
341
344
}
342
345
}
346
+
347
+ // If script analysis is enabled and the settings file changed get new diagnostic records.
348
+ if ( this . currentSettings . ScriptAnalysis . Enable . Value && settingsPathChanged )
349
+ {
350
+ await this . RunScriptDiagnostics (
351
+ this . editorSession . Workspace . GetOpenedFiles ( ) ,
352
+ this . editorSession ,
353
+ eventContext ) ;
354
+ }
343
355
}
344
356
}
345
357
0 commit comments