[analysis_server] Fix handling of "Do not show again" on Dart fix prompt
A recent change to support in-editor "dart fix" changed the switch expression here in a way that the handling of "Do not show again" no longer matched and apparently this case had no test 😔
This fixes the check and adds the missing test.
Fixes https://github.com/Dart-Code/Dart-Code/issues/5202
Change-Id: I4fe182824a103d77b88e3a84d941f722f071f117
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/377940
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/services/user_prompts/dart_fix_prompt_manager.dart b/pkg/analysis_server/lib/src/services/user_prompts/dart_fix_prompt_manager.dart
index 2dc00a2..aed8fd0 100644
--- a/pkg/analysis_server/lib/src/services/user_prompts/dart_fix_prompt_manager.dart
+++ b/pkg/analysis_server/lib/src/services/user_prompts/dart_fix_prompt_manager.dart
@@ -202,7 +202,7 @@
: Commands.previewFixAllInWorkspace;
unawaited(_executeCommand(execHandler, userPromptSender, command));
- case doNotShowAgainActionText:
+ case (doNotShowAgainActionText, _):
preferences.showDartFixPrompts = false;
default:
diff --git a/pkg/analysis_server/test/services/user_prompts/dart_fix_prompt_manager_test.dart b/pkg/analysis_server/test/services/user_prompts/dart_fix_prompt_manager_test.dart
index 48919bd..0eccf51 100644
--- a/pkg/analysis_server/test/services/user_prompts/dart_fix_prompt_manager_test.dart
+++ b/pkg/analysis_server/test/services/user_prompts/dart_fix_prompt_manager_test.dart
@@ -234,6 +234,15 @@
expect(promptManager.promptsShown, 0);
}
+ Future<void> test_prompt_recordsDoNotShowAgain() async {
+ server.respondToPromptWithAction =
+ DartFixPromptManager.doNotShowAgainActionText;
+ promptManager.triggerCheck();
+ await pumpEventQueue(times: 5000);
+ expect(promptManager.promptsShown, 1);
+ expect(promptManager.preferences.showDartFixPrompts, false);
+ }
+
Future<void> test_promptKind_external_noApplyEdit() async {
configureInEditorPromptSupport(
applyEditSupport: false,