diff --git a/src/extension.ts b/src/extension.ts index dfa32e2..9be069a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -6,6 +6,9 @@ import { documentationLinkMap, getPremiumCertLink } from './util/documentation'; import { runCommand } from './util/scripts'; import { looksLikePath, resolvePath, findWorkspaceRoot } from './util/path'; +let cppcheckProgressIndicator: vscode.StatusBarItem; +let checksRunning = false; + enum SeverityNumber { Info = 0, Warning = 1, @@ -64,6 +67,15 @@ function parseMinSeverity(str: string): SeverityNumber { } } +function updateProgressIndicator(): void { + if (checksRunning) { + cppcheckProgressIndicator.text = `$(loading~spin) Cppcheck Running ..`; + cppcheckProgressIndicator.show(); + } else { + cppcheckProgressIndicator.hide(); + } +} + // This method is called when your extension is activated. // Your extension is activated the very first time the command is executed. export async function activate(context: vscode.ExtensionContext) { @@ -81,6 +93,10 @@ export async function activate(context: vscode.ExtensionContext) { ) ); + // ProgressIndicator status bar item to show when checks are running + cppcheckProgressIndicator = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left, 10); + context.subscriptions.push(cppcheckProgressIndicator); + // Create a diagnostic collection. const diagnosticCollection = vscode.languages.createDiagnosticCollection("Cppcheck"); context.subscriptions.push(diagnosticCollection); @@ -203,6 +219,9 @@ async function runCppcheckOnFileXML( minSevString: string, diagnosticCollection: vscode.DiagnosticCollection ): Promise { + checksRunning = true; + updateProgressIndicator(); + // Clear existing diagnostics for this file diagnosticCollection.delete(document.uri); @@ -352,6 +371,9 @@ async function runCppcheckOnFileXML( diagnosticCollection.set(document.uri, diagnostics); }); }); + + checksRunning = false; + updateProgressIndicator(); } // This method is called when your extension is deactivated