From 6443e9d9e2ded05d73db73debba866641c99f695 Mon Sep 17 00:00:00 2001 From: Rajpreet Singh Date: Thu, 26 Sep 2024 16:25:07 +0530 Subject: [PATCH] fixed policy violation not triggering when manifest file is already opened --- src/extension.ts | 2 +- src/providers/index.ts | 4 ++++ src/services/scanService.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/extension.ts b/src/extension.ts index e70d0a2..cedeafd 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -36,7 +36,6 @@ export async function activate(context: vscode.ExtensionContext) { await debrickedCommand.commands(context); await providers.registerHover(context); - await providers.registerDependencyPolicyProvider(context); const debCommandsProvider = new DebrickedCommandsTreeDataProvider(); vscode.window.registerTreeDataProvider(Organization.debrickedCommand, debCommandsProvider); @@ -64,6 +63,7 @@ export async function activate(context: vscode.ExtensionContext) { // Add file watcher for all files found from 'debricked files find' await watchers.registerWatcher(context); + await providers.registerDependencyPolicyProvider(context); // after adding watcher and scanning we should add the policy provider progress.report({ message: "Debricked extension is ready to use", increment: 100 - progressCount }); await new Promise((resolve) => setTimeout(resolve, 1000)); // added for showing the last progress info diff --git a/src/providers/index.ts b/src/providers/index.ts index 945a07a..8493b4f 100644 --- a/src/providers/index.ts +++ b/src/providers/index.ts @@ -37,6 +37,10 @@ class Providers { context.subscriptions.push(diagnosticCollection); const provider = new DependencyPolicyProvider(diagnosticCollection); + //added to activate the policy violation provider when the manifest file is already open + if (vscode.window.activeTextEditor?.document) { + provider.checkPolicyViolation(vscode.window.activeTextEditor?.document); + } context.subscriptions.push( vscode.languages.registerCodeActionsProvider({ scheme: "file" }, provider, { diff --git a/src/services/scanService.ts b/src/services/scanService.ts index 18eafca..b34079a 100644 --- a/src/services/scanService.ts +++ b/src/services/scanService.ts @@ -54,7 +54,7 @@ export class ScanService { } } - vscode.window.withProgress( + await vscode.window.withProgress( { location: vscode.ProgressLocation.Window, title: Organization.nameCaps,