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 801cc83..fb8a2e5 100644 --- a/editor-plugin/src/extension.ts +++ b/editor-plugin/src/extension.ts @@ -61,14 +61,27 @@ 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( + '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); + } + }); + } +} + export function deactivate() { return new Promise((resolve) => { client.sendRequest('shutdown').then(() => {