about summary refs log tree commit diff
path: root/editors/code/src
diff options
context:
space:
mode:
authorYoung-Flash <dongyang@apache.org>2024-01-22 18:49:39 +0800
committerYoung-Flash <dongyang@apache.org>2024-01-22 18:49:39 +0800
commite15f40e8425bea5a225f7b1a7d0492a7ef962a09 (patch)
treebd0faf8ba393528dae121d81ea1a027f5b9a7727 /editors/code/src
parent3f4c6dac3d5e34ccf56587419c2077aec799e60c (diff)
feat: add conflict ext (panicbit.cargo) detect
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/main.ts40
1 files changed, 29 insertions, 11 deletions
diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts
index 599cfb4ff77..001d2bbadf3 100644
--- a/editors/code/src/main.ts
+++ b/editors/code/src/main.ts
@@ -25,16 +25,7 @@ export async function deactivate() {
 export async function activate(
     context: vscode.ExtensionContext,
 ): Promise<RustAnalyzerExtensionApi> {
-    if (vscode.extensions.getExtension("rust-lang.rust")) {
-        vscode.window
-            .showWarningMessage(
-                `You have both the rust-analyzer (rust-lang.rust-analyzer) and Rust (rust-lang.rust) ` +
-                    "plugins enabled. These are known to conflict and cause various functions of " +
-                    "both plugins to not work correctly. You should disable one of them.",
-                "Got it",
-            )
-            .then(() => {}, console.error);
-    }
+    conflictExtDetect();
 
     const ctx = new Ctx(context, createCommands(), fetchWorkspace());
     // VS Code doesn't show a notification when an extension fails to activate
@@ -149,7 +140,7 @@ function createCommands(): Record<string, CommandFactory> {
                     health: "stopped",
                 });
             },
-            disabled: (_) => async () => {},
+            disabled: (_) => async () => { },
         },
 
         analyzerStatus: { enabled: commands.analyzerStatus },
@@ -200,3 +191,30 @@ function createCommands(): Record<string, CommandFactory> {
         revealDependency: { enabled: commands.revealDependency },
     };
 }
+
+function conflictExtDetect() {
+    if (vscode.extensions.getExtension("rust-lang.rust")) {
+        vscode.window
+            .showWarningMessage(
+                `You have both the rust-analyzer (rust-lang.rust-analyzer) and Rust (rust-lang.rust) ` +
+                "plugins enabled. These are known to conflict and cause various functions of " +
+                "both plugins to not work correctly. You should disable one of them.",
+                "Got it"
+            )
+            .then(() => { }, console.error);
+    }
+
+    if (vscode.extensions.getExtension("panicbit.cargo")) {
+        let isRustAnalyzerCheckOnSave = vscode.workspace.getConfiguration("rust-analyzer").get("checkOnSave");
+        let isCargoAutomaticCheck = vscode.workspace.getConfiguration("cargo").get("automaticCheck");
+        if (isRustAnalyzerCheckOnSave && isCargoAutomaticCheck) {
+            vscode.window
+                .showWarningMessage(
+                    `You have Cargo (panicbit.cargo) enabled with 'cargo.automaticCheck' set to true(default), ` +
+                    "you can disable it or set {\"cargo.automaticCheck\": false} in settings.json to avoid invoke cargo twice",
+                    "Got it"
+                )
+                .then(() => { }, console.error);
+        }
+    }
+}
\ No newline at end of file