Skip to content

Commit 076ce90

Browse files
committed
Now the diagnostics records update when you change the scriptAnalysisSettingsPath.
1 parent ddc2f9e commit 076ce90

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,17 +318,20 @@ protected async Task HandleDidChangeConfigurationNotification(
318318
}
319319

320320
// If there is a new settings file path, restart the analyzer with the new settigs.
321+
bool settingsPathChanged = false;
321322
string newSettingsPath = this.currentSettings.ScriptAnalysis.SettingsPath;
322323
if (!(oldScriptAnalysisSettingsPath?.Equals(newSettingsPath, StringComparison.OrdinalIgnoreCase) ?? false))
323324
{
324325
this.editorSession.RestartAnalysisService(newSettingsPath);
326+
settingsPathChanged = true;
325327
}
326328

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)
328331
{
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)
332335
{
333336
ScriptFileMarker[] emptyAnalysisDiagnostics = new ScriptFileMarker[0];
334337

@@ -340,6 +343,15 @@ await PublishScriptDiagnostics(
340343
eventContext);
341344
}
342345
}
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+
}
343355
}
344356
}
345357

0 commit comments

Comments
 (0)