[
https://issues.apache.org/jira/browse/GROOVY-12436?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18128979#comment-18128979
]
Paul King commented on GROOVY-12436:
------------------------------------
Okay, looks like a JDK27 thing not a macOS specific thing.
> GroovyConsole key bindings lost after runtime theme switch
> ----------------------------------------------------------
>
> Key: GROOVY-12436
> URL: https://issues.apache.org/jira/browse/GROOVY-12436
> Project: Groovy
> Issue Type: Bug
> Components: groovy-console
> Affects Versions: 6.0.0
> Environment: macOS 26.7.1 (25G241)
> Reporter: marslo
> Priority: Critical
>
> h2. Summary
> GroovyConsole input editor loses key bindings (Enter, Backspace, etc.) after
> switching the theme at runtime (e.g. View → Theme → Dark, or the Preferences
> "Reload Themes" button).
> h2. Environment
> * Groovy 6.0.0
> * macOS (Darwin), Java Swing GUI
> * Reproduced with the bundled dark theme — no custom theme required
> {code:bash}
> $ groovy --version
> Groovy Version: 6.0.0 JVM: 27 Vendor: Homebrew OS: Mac OS X
> $ sw_vers
> ProductName: macOS
> ProductVersion: 26.7.1
> BuildVersion: 25G241
> {code}
> h2. Steps to reproduce
> # Launch groovyConsole while the OS appearance resolves to light (default
> theme mode is SYSTEM).
> # Switch the theme at runtime via View → Theme → Dark (or load a custom
> theme and click Preferences → Reload Themes).
> # Click into the input editor and press Enter or Backspace.
> h2. Expected
> Enter inserts a newline (with auto-indent); Backspace deletes the previous
> character.
> h2. Actual
> Enter / Backspace (and other editor keys) no longer respond in the input
> editor until the console is restarted.
> h2. Workaround
> Set the desired theme, fully quit (⌘Q), and relaunch. On startup
> {{ThemeManager.applyTheme()}} runs before the editor is built, so no runtime
> {{updateUI()}} occurs and key bindings stay intact.
> h2. Likely root cause
> {{Console.reapplyStyles()}} ends with {{{}FlatLaf.updateUI(){}}}, which runs
> updateComponentTreeUI() over all windows and reinstalls the text component UI
> delegates, resetting the input editor's InputMap/keymap. The custom bindings
> installed in {{ConsoleTextEditor}} (and the editor-kit default edit actions)
> are not re-installed afterward, so editor keys stop working until the
> component tree is rebuilt (restart / new window).
> Call chain:
> {code:bash}
> reloadThemes() → reapplyTheme() → switchTheme() → reapplyStyles() →
> FlatLaf.updateUI(){code}
> Introduced by GROOVY-11932 (PR apache/groovy#2469, "Allow theme switching
> light/dark/system in groovyConsole").
> h2. Suggested fix
> Re-install the input editor's key bindings after {{FlatLaf.updateUI()}} in
> {{{}reapplyStyles(){}}}, or avoid the full {{updateComponentTreeUI()}} sweep
> over the editor component (update only colors/styles that actually changed).
--
This message was sent by Atlassian Jira
(v8.20.10#820010)