From b7a251e7d823d86cef87c32611fac41240f454b4 Mon Sep 17 00:00:00 2001 From: Aleksandra Olemskaia Date: Wed, 17 Jun 2026 18:30:35 +0200 Subject: [PATCH] [settings] IJPL-245888 preserve unsaved color scheme edits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a non-modal Settings dialog is open with unsaved color scheme edits, any code that enumerates configurables (Search Everywhere, reopening Settings via shortcut) triggers buildConfigurables() on a new ColorAndFontOptions instance. This calls initAll() → dropSchemes() on the shared ColorAndFontOptionsModel singleton, wiping the unsaved edits. Guard buildConfigurables() to skip initAll() when the shared model already contains MyColorScheme objects from an active instance. (cherry picked from commit b420c50c7f5a8be55ea3506dc0988712c27aeab8) IJ-CR-210036 GitOrigin-RevId: 5678c13eaf4805ba2d65f7a6e698f46b0f5e060d --- .../options/colors/ColorAndFontOptions.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/platform-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java b/platform/platform-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java index 67cce4515bd2..32f5a12932c2 100644 --- a/platform/platform-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java +++ b/platform/platform-impl/src/com/intellij/application/options/colors/ColorAndFontOptions.java @@ -527,7 +527,13 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract @Override public @NotNull Configurable @NotNull [] buildConfigurables() { myDisposeCompleted = false; - initAll(); + // Skip initAll() if the shared model already contains MyColorScheme objects from another active + // ColorAndFontOptions instance (e.g. an open non-modal Settings dialog). Calling initAll() would + // wipe unsaved edits via dropSchemes(). This path is hit when Search Everywhere or other code + // enumerates configurables and triggers buildConfigurables() on a throwaway instance. + if (!hasMyColorSchemesInModel()) { + initAll(); + } List panelFactories = createPanelFactories(); @@ -669,6 +675,13 @@ public class ColorAndFontOptions extends SearchableConfigurable.Parent.Abstract } } + private boolean hasMyColorSchemesInModel() { + for (EditorColorsScheme scheme : myModel.allSchemes()) { + if (scheme instanceof MyColorScheme) return true; + } + return false; + } + private void initAll() { EditorColorsScheme globalScheme = EditorColorsManager.getInstance().getGlobalScheme();