@@ -463,7 +463,7 @@ protected async Task HandleDidChangeConfigurationNotification(
463
463
{
464
464
bool oldLoadProfiles = this . currentSettings . EnableProfileLoading ;
465
465
bool oldScriptAnalysisEnabled =
466
- this . currentSettings . ScriptAnalysis . Enable . HasValue ;
466
+ this . currentSettings . ScriptAnalysis . Enable . HasValue ? this . currentSettings . ScriptAnalysis . Enable . Value : false ;
467
467
string oldScriptAnalysisSettingsPath =
468
468
this . currentSettings . ScriptAnalysis . SettingsPath ;
469
469
@@ -501,14 +501,10 @@ protected async Task HandleDidChangeConfigurationNotification(
501
501
}
502
502
}
503
503
504
- // If script analysis is enabled and the settings file changed get new diagnostic records.
505
- if ( this . currentSettings . ScriptAnalysis . Enable . Value && settingsPathChanged )
506
- {
507
- await this . RunScriptDiagnostics (
508
- this . editorSession . Workspace . GetOpenedFiles ( ) ,
509
- this . editorSession ,
510
- eventContext ) ;
511
- }
504
+ await this . RunScriptDiagnostics (
505
+ this . editorSession . Workspace . GetOpenedFiles ( ) ,
506
+ this . editorSession ,
507
+ eventContext ) ;
512
508
}
513
509
}
514
510
@@ -1078,12 +1074,6 @@ private Task RunScriptDiagnostics(
1078
1074
EditorSession editorSession ,
1079
1075
Func < EventType < PublishDiagnosticsNotification > , PublishDiagnosticsNotification , Task > eventSender )
1080
1076
{
1081
- if ( ! this . currentSettings . ScriptAnalysis . Enable . Value )
1082
- {
1083
- // If the user has disabled script analysis, skip it entirely
1084
- return Task . FromResult ( true ) ;
1085
- }
1086
-
1087
1077
// If there's an existing task, attempt to cancel it
1088
1078
try
1089
1079
{
@@ -1122,6 +1112,7 @@ private Task RunScriptDiagnostics(
1122
1112
DelayThenInvokeDiagnostics (
1123
1113
750 ,
1124
1114
filesToAnalyze ,
1115
+ this . currentSettings . ScriptAnalysis . Enable . Value ,
1125
1116
this . codeActionsPerFile ,
1126
1117
editorSession ,
1127
1118
eventSender ,
@@ -1133,10 +1124,10 @@ private Task RunScriptDiagnostics(
1133
1124
return Task . FromResult ( true ) ;
1134
1125
}
1135
1126
1136
-
1137
1127
private static async Task DelayThenInvokeDiagnostics (
1138
1128
int delayMilliseconds ,
1139
1129
ScriptFile [ ] filesToAnalyze ,
1130
+ bool isScriptAnalysisEnabled ,
1140
1131
Dictionary < string , Dictionary < string , MarkerCorrection > > correctionIndex ,
1141
1132
EditorSession editorSession ,
1142
1133
EventContext eventContext ,
@@ -1145,6 +1136,7 @@ private static async Task DelayThenInvokeDiagnostics(
1145
1136
await DelayThenInvokeDiagnostics (
1146
1137
delayMilliseconds ,
1147
1138
filesToAnalyze ,
1139
+ isScriptAnalysisEnabled ,
1148
1140
correctionIndex ,
1149
1141
editorSession ,
1150
1142
eventContext . SendEvent ,
@@ -1155,6 +1147,7 @@ await DelayThenInvokeDiagnostics(
1155
1147
private static async Task DelayThenInvokeDiagnostics (
1156
1148
int delayMilliseconds ,
1157
1149
ScriptFile [ ] filesToAnalyze ,
1150
+ bool isScriptAnalysisEnabled ,
1158
1151
Dictionary < string , Dictionary < string , MarkerCorrection > > correctionIndex ,
1159
1152
EditorSession editorSession ,
1160
1153
Func < EventType < PublishDiagnosticsNotification > , PublishDiagnosticsNotification , Task > eventSender ,
@@ -1183,7 +1176,7 @@ private static async Task DelayThenInvokeDiagnostics(
1183
1176
foreach ( ScriptFile scriptFile in filesToAnalyze )
1184
1177
{
1185
1178
ScriptFileMarker [ ] semanticMarkers = null ;
1186
- if ( editorSession . AnalysisService != null )
1179
+ if ( isScriptAnalysisEnabled && editorSession . AnalysisService != null )
1187
1180
{
1188
1181
Logger . Write ( LogLevel . Verbose , "Analyzing script file: " + scriptFile . FilePath ) ;
1189
1182
@@ -1199,10 +1192,10 @@ private static async Task DelayThenInvokeDiagnostics(
1199
1192
// isn't available
1200
1193
semanticMarkers = new ScriptFileMarker [ 0 ] ;
1201
1194
}
1202
- var allMarkers = scriptFile . SyntaxMarkers . Concat ( semanticMarkers ) ;
1195
+
1203
1196
await PublishScriptDiagnostics (
1204
1197
scriptFile ,
1205
- semanticMarkers ,
1198
+ scriptFile . SyntaxMarkers . Concat ( semanticMarkers ) . ToArray ( ) ,
1206
1199
correctionIndex ,
1207
1200
eventSender ) ;
1208
1201
}
@@ -1220,20 +1213,20 @@ await PublishScriptDiagnostics(
1220
1213
1221
1214
private static async Task PublishScriptDiagnostics (
1222
1215
ScriptFile scriptFile ,
1223
- ScriptFileMarker [ ] semanticMarkers ,
1216
+ ScriptFileMarker [ ] markers ,
1224
1217
Dictionary < string , Dictionary < string , MarkerCorrection > > correctionIndex ,
1225
1218
EventContext eventContext )
1226
1219
{
1227
1220
await PublishScriptDiagnostics (
1228
1221
scriptFile ,
1229
- semanticMarkers ,
1222
+ markers ,
1230
1223
correctionIndex ,
1231
1224
eventContext . SendEvent ) ;
1232
1225
}
1233
1226
1234
1227
private static async Task PublishScriptDiagnostics (
1235
1228
ScriptFile scriptFile ,
1236
- ScriptFileMarker [ ] semanticMarkers ,
1229
+ ScriptFileMarker [ ] markers ,
1237
1230
Dictionary < string , Dictionary < string , MarkerCorrection > > correctionIndex ,
1238
1231
Func < EventType < PublishDiagnosticsNotification > , PublishDiagnosticsNotification , Task > eventSender )
1239
1232
{
@@ -1243,7 +1236,7 @@ private static async Task PublishScriptDiagnostics(
1243
1236
Dictionary < string , MarkerCorrection > fileCorrections =
1244
1237
new Dictionary < string , MarkerCorrection > ( ) ;
1245
1238
1246
- foreach ( var marker in scriptFile . SyntaxMarkers . Concat ( semanticMarkers ) )
1239
+ foreach ( var marker in markers )
1247
1240
{
1248
1241
// Does the marker contain a correction?
1249
1242
Diagnostic markerDiagnostic = GetDiagnosticFromMarker ( marker ) ;
0 commit comments