From ca8b443cd6373e557c2fe33c5240305390e10818 Mon Sep 17 00:00:00 2001 From: MuhammadHassnain Date: Tue, 28 Apr 2026 16:36:06 -0700 Subject: [PATCH 1/2] Added code lens warning --- editor-plugin/src/extension.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/editor-plugin/src/extension.ts b/editor-plugin/src/extension.ts index 801cc83..38e499b 100644 --- a/editor-plugin/src/extension.ts +++ b/editor-plugin/src/extension.ts @@ -61,6 +61,18 @@ export function activate(context: vscode.ExtensionContext) { client.start(); outputChannel.appendLine('Cargo Scan extension is now active!'); + + const editorConfig = vscode.workspace.getConfiguration('editor'); + if (editorConfig.get('codeLens') === false) { + vscode.window.showWarningMessage( + 'Cargo Scan uses CodeLens to display review buttons. Please enable it to use the extension.', + 'Enable CodeLens' + ).then((selection) => { + if (selection === 'Enable CodeLens') { + editorConfig.update('codeLens', true, vscode.ConfigurationTarget.Global); + } + }); + } // Register everything From 36f6f227e3c57a29fe12f82d883ab7a6b38d2470 Mon Sep 17 00:00:00 2001 From: MuhammadHassnain Date: Wed, 29 Apr 2026 23:55:46 -0700 Subject: [PATCH 2/2] warning fires when audit command is invoked --- editor-plugin/src/commands.ts | 4 +++- editor-plugin/src/extension.ts | 13 +++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/editor-plugin/src/commands.ts b/editor-plugin/src/commands.ts index 0ec2b36..58ec327 100644 --- a/editor-plugin/src/commands.ts +++ b/editor-plugin/src/commands.ts @@ -1,6 +1,6 @@ import * as vscode from 'vscode'; import { EffectResponseData, EffectsResponse, LocationItem } from './file_tree_view'; -import { annotations, client, locationsProvider } from './extension'; +import { annotations, client, locationsProvider, warnIfCodeLensDisabled } from './extension'; import { AuditResponse } from './audit_annotations'; import { convertLocation } from './util'; import { highlightEffectLocations } from './decorations'; @@ -25,6 +25,7 @@ export function registerCommands(context: vscode.ExtensionContext) { context.subscriptions.push( vscode.commands.registerCommand('cargo-scan.audit', async () => { + warnIfCodeLensDisabled(); vscode.window.withProgress( { location: vscode.ProgressLocation.Notification, @@ -126,6 +127,7 @@ export function registerCommands(context: vscode.ExtensionContext) { context.subscriptions.push( vscode.commands.registerCommand('cargo-scan.audit_chain', async () => { + warnIfCodeLensDisabled(); const response = await client.sendRequest('cargo-scan.audit_chain'); context.globalState.update('annotateEffects', true); context.globalState.update('chainAudit', true); diff --git a/editor-plugin/src/extension.ts b/editor-plugin/src/extension.ts index 38e499b..fb8a2e5 100644 --- a/editor-plugin/src/extension.ts +++ b/editor-plugin/src/extension.ts @@ -62,6 +62,13 @@ export function activate(context: vscode.ExtensionContext) { client.start(); outputChannel.appendLine('Cargo Scan extension is now active!'); + // Register everything + registerCommands(context); + annotations.register(context); + locationsProvider.register(context); +} + +export function warnIfCodeLensDisabled() { const editorConfig = vscode.workspace.getConfiguration('editor'); if (editorConfig.get('codeLens') === false) { vscode.window.showWarningMessage( @@ -73,12 +80,6 @@ export function activate(context: vscode.ExtensionContext) { } }); } - - - // Register everything - registerCommands(context); - annotations.register(context); - locationsProvider.register(context); } export function deactivate() {