Skip to content

Commit e15f40e

Browse files
committed
feat: add conflict ext (panicbit.cargo) detect
1 parent 3f4c6da commit e15f40e

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

editors/code/src/main.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,7 @@ export async function deactivate() {
2525
export async function activate(
2626
context: vscode.ExtensionContext,
2727
): Promise<RustAnalyzerExtensionApi> {
28-
if (vscode.extensions.getExtension("rust-lang.rust")) {
29-
vscode.window
30-
.showWarningMessage(
31-
`You have both the rust-analyzer (rust-lang.rust-analyzer) and Rust (rust-lang.rust) ` +
32-
"plugins enabled. These are known to conflict and cause various functions of " +
33-
"both plugins to not work correctly. You should disable one of them.",
34-
"Got it",
35-
)
36-
.then(() => {}, console.error);
37-
}
28+
conflictExtDetect();
3829

3930
const ctx = new Ctx(context, createCommands(), fetchWorkspace());
4031
// VS Code doesn't show a notification when an extension fails to activate
@@ -149,7 +140,7 @@ function createCommands(): Record<string, CommandFactory> {
149140
health: "stopped",
150141
});
151142
},
152-
disabled: (_) => async () => {},
143+
disabled: (_) => async () => { },
153144
},
154145

155146
analyzerStatus: { enabled: commands.analyzerStatus },
@@ -200,3 +191,30 @@ function createCommands(): Record<string, CommandFactory> {
200191
revealDependency: { enabled: commands.revealDependency },
201192
};
202193
}
194+
195+
function conflictExtDetect() {
196+
if (vscode.extensions.getExtension("rust-lang.rust")) {
197+
vscode.window
198+
.showWarningMessage(
199+
`You have both the rust-analyzer (rust-lang.rust-analyzer) and Rust (rust-lang.rust) ` +
200+
"plugins enabled. These are known to conflict and cause various functions of " +
201+
"both plugins to not work correctly. You should disable one of them.",
202+
"Got it"
203+
)
204+
.then(() => { }, console.error);
205+
}
206+
207+
if (vscode.extensions.getExtension("panicbit.cargo")) {
208+
let isRustAnalyzerCheckOnSave = vscode.workspace.getConfiguration("rust-analyzer").get("checkOnSave");
209+
let isCargoAutomaticCheck = vscode.workspace.getConfiguration("cargo").get("automaticCheck");
210+
if (isRustAnalyzerCheckOnSave && isCargoAutomaticCheck) {
211+
vscode.window
212+
.showWarningMessage(
213+
`You have Cargo (panicbit.cargo) enabled with 'cargo.automaticCheck' set to true(default), ` +
214+
"you can disable it or set {\"cargo.automaticCheck\": false} in settings.json to avoid invoke cargo twice",
215+
"Got it"
216+
)
217+
.then(() => { }, console.error);
218+
}
219+
}
220+
}

0 commit comments

Comments
 (0)