From 49bb3f5b35a959c4c36bf816ae4b5e067db66191 Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Sat, 17 Feb 2024 11:10:42 +0100 Subject: [PATCH] Remove win.defender.startup.check.skip preference if disabled for all Removing the preference node from the user-scope instead of setting the value to false (if it was true before) allows the preference service to consider the value of higher-level scopes like the default scope defined in a product. --- .../eclipse/ui/internal/WindowsDefenderConfigurator.java | 6 +++++- .../eclipse/ui/internal/dialogs/StartupPreferencePage.java | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WindowsDefenderConfigurator.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WindowsDefenderConfigurator.java index 10d87544798..135aac4a201 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WindowsDefenderConfigurator.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WindowsDefenderConfigurator.java @@ -240,7 +240,11 @@ public static IEclipsePreferences getPreference(IScopeContext instance) { public static void savePreference(IScopeContext scope, String key, String value) throws CoreException { IEclipsePreferences preferences = getPreference(scope); - preferences.put(key, value); + if (value != null) { + preferences.put(key, value); + } else { + preferences.remove(key); + } try { preferences.flush(); } catch (BackingStoreException e) { diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/StartupPreferencePage.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/StartupPreferencePage.java index 58a290a16b2..aa856feccb7 100644 --- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/StartupPreferencePage.java +++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/StartupPreferencePage.java @@ -237,7 +237,8 @@ public boolean performOk() { windowsDefenderIgnore.forEach((scope, button) -> { try { - String skip = Boolean.toString(button.getSelection()); + // If disabled remove the node to allow higher-level scopes to be considered + String skip = button.getSelection() ? Boolean.TRUE.toString() : null; WindowsDefenderConfigurator.savePreference(scope, PREFERENCE_STARTUP_CHECK_SKIP, skip); } catch (CoreException e) { WorkbenchPlugin.log("Failed to save Windows Defender exclusion check preferences", e); //$NON-NLS-1$