From 93956d32f9f1ff2721e5260292c4ad2226e844f1 Mon Sep 17 00:00:00 2001 From: Denis Moslavac Date: Fri, 20 Dec 2024 11:32:13 +0100 Subject: [PATCH] Refactoring of deactivateCoverage --- src/coverage.ts | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/coverage.ts b/src/coverage.ts index 48ba4e72..e9e75f3e 100644 --- a/src/coverage.ts +++ b/src/coverage.ts @@ -277,15 +277,26 @@ export async function updateCOVdecorations() { } function deactivateCoverage() { - // delete all decorations - if (uncoveredDecorationType) uncoveredDecorationType.dispose(); - if (coveredDecorationType) coveredDecorationType.dispose(); - if (partiallyCoveredDecorationType) partiallyCoveredDecorationType.dispose(); - if (coveredDecorationTypeWithMCDC) coveredDecorationTypeWithMCDC.dispose(); - if (uncoveredDecorationTypeWithMCDC) - uncoveredDecorationTypeWithMCDC.dispose(); - if (partiallyCoveredDecorationTypeWithMCDC) - partiallyCoveredDecorationTypeWithMCDC.dispose(); + const decorationTypes = [ + uncoveredDecorationType, + coveredDecorationType, + partiallyCoveredDecorationType, + coveredDecorationTypeWithMCDC, + uncoveredDecorationTypeWithMCDC, + partiallyCoveredDecorationTypeWithMCDC, + ]; + + // Debug log to verify contents of decorationTypes + console.log("Decoration Types Before Disposal:", decorationTypes); + + // Iterate over the list and dispose of each decoration type if it exists + for (const decorationType of decorationTypes) { + if (decorationType) { + console.log("Disposing decoration type:", decorationType); + decorationType.dispose(); + } + } + coverageStatusBarObject.hide(); }