minor: update conflict extension detect logic

This commit is contained in:
Young-Flash 2024-01-26 20:12:13 +08:00
parent 56f54c87e7
commit 96ebad0409

View file

@ -25,7 +25,7 @@ export async function deactivate() {
export async function activate( export async function activate(
context: vscode.ExtensionContext, context: vscode.ExtensionContext,
): Promise<RustAnalyzerExtensionApi> { ): Promise<RustAnalyzerExtensionApi> {
conflictExtDetect(); checkConflictingExtensions();
const ctx = new Ctx(context, createCommands(), fetchWorkspace()); const ctx = new Ctx(context, createCommands(), fetchWorkspace());
// VS Code doesn't show a notification when an extension fails to activate // VS Code doesn't show a notification when an extension fails to activate
@ -192,7 +192,7 @@ function createCommands(): Record<string, CommandFactory> {
}; };
} }
function conflictExtDetect() { function checkConflictingExtensions() {
if (vscode.extensions.getExtension("rust-lang.rust")) { if (vscode.extensions.getExtension("rust-lang.rust")) {
vscode.window vscode.window
.showWarningMessage( .showWarningMessage(
@ -205,20 +205,12 @@ function conflictExtDetect() {
} }
if (vscode.extensions.getExtension("panicbit.cargo")) { if (vscode.extensions.getExtension("panicbit.cargo")) {
const isRustAnalyzerCheckOnSave = vscode.workspace vscode.window
.getConfiguration("rust-analyzer") .showWarningMessage(
.get("checkOnSave"); `You have both the rust-analyzer (rust-lang.rust-analyzer) and Cargo (panicbit.cargo) ` +
const isCargoAutomaticCheck = vscode.workspace 'you can disable it or set {"cargo.automaticCheck": false} in settings.json to avoid invoking cargo twice',
.getConfiguration("cargo") "Got it",
.get("automaticCheck"); )
if (isRustAnalyzerCheckOnSave && isCargoAutomaticCheck) { .then(() => {}, console.error);
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);
}
} }
} }