Reset defaults by setting value rather than remove by Stefterv · Pull Request #1385 · processing/processing4

Expand Up @@ -27,6 +27,7 @@ import androidx.compose.ui.window.application import com.mikepenz.markdown.compose.Markdown import com.mikepenz.markdown.m3.markdownColor import com.mikepenz.markdown.m3.markdownTypography import processing.app.DEFAULTS_FILE_NAME import processing.app.LocalPreferences import processing.app.ReactiveProperties import processing.app.ui.PDEPreferences.Companion.preferences Expand All @@ -35,6 +36,7 @@ import processing.app.ui.theme.* import java.awt.Dimension import java.awt.event.WindowEvent import java.awt.event.WindowListener import java.util.* import javax.swing.SwingUtilities import javax.swing.WindowConstants
Expand Down Expand Up @@ -593,9 +595,16 @@ fun PDEPreferencePane.showPane(groups: PDEPreferenceGroups) { val prefs = LocalPreferences.current TextButton( onClick = { val defaultsStream = ClassLoader.getSystemResourceAsStream(DEFAULTS_FILE_NAME) ?: return@TextButton val defaults = Properties().apply { defaultsStream.reader(Charsets.UTF_8).use { load(it) } } groups.forEach { group -> group.forEach { pref -> prefs.remove(pref.key) prefs[pref.key] = defaults.getProperty(pref.key, "") } } } Expand Down