[settings] IJPL-245888 preserve unsaved color scheme edits

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
This commit is contained in:
Aleksandra Olemskaia
2026-06-24 15:26:00 +00:00
committed by intellij-monorepo-bot
parent 73f543d3d5
commit b7a251e7d8
@@ -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<ColorAndFontPanelFactory> 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();