Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion editor-plugin/src/commands.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -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<AuditResponse>('cargo-scan.audit_chain');
context.globalState.update('annotateEffects', true);
context.globalState.update('chainAudit', true);
Expand Down
17 changes: 15 additions & 2 deletions editor-plugin/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<boolean>('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<void>((resolve) => {
client.sendRequest('shutdown').then(() => {
Expand Down
Loading