Skip to content

Commit

Permalink
Remove win.defender.startup.check.skip preference if disabled for all
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
HannesWell committed Feb 17, 2024
1 parent 6d495fc commit 49bb3f5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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$
Expand Down

0 comments on commit 49bb3f5

Please sign in to comment.