This article describes how to report issues with focus in IntelliJ based IDEs. If possible, perform all of the steps below. However, you can also provide just the basic info by skipping the bullet points and only following the numbers:
- Make sure IDE is in internal mode
- Open “Settings | Keymap” and assign a shortcut to “Internal Actions | UI | Dump Focusable Component Hierarchy”
- Reproduce the problem
- Once the focus is lost, determine what component is focused:
- Invoke “Dump Focusable Component Hierarchy” with a shortcut
- Scroll down
- Press “Close and copy into the clipboard”
- Create a new issue in YouTrack
- Paste the info from the clipboard into the issue description
- Optional: enable “Internal Actions | UI | Start focus debugger” and provide a screencast or a screenshot of how focus lost happens
- Optional: check if the problem persists when using OpenJDK 11 as boot JDK. Use Choose Runtime plugin to switch
- Extra helpful: Collect JDK logs (instruction below)
How to collect JDK logs
The aim is to determine what’s wrong with the focus events. An approach described below is based on comparing focus events between the two IDE builds - broken and working.
1. Get the logging.properties file
2. Specify the path to the downloaded file in the IDE “.vmoptions” file (Help | Edit Custom VM Options):
3. Run the IDE from the console
The console should become flooded with focus events. Note that events are produced every time when focused component changes. In case you don’t see them, go to the section Setting up “logging.properties” below
4. Recreate the problem. Every time a focus event appears, copy it to a text file
5. Repeat steps 2-4 on IDE instance that isn’t affected by the issue (use some of the previous builds - see "Other Versions" section on IDE download page, or roll back if you use Toolbox)
6. Compare focus events during normal and buggy scenarios. Likely you’ll notice that some events are missing when the bug happens - that’s the key that will help to fix it. See an example of an investigation
7. Once finished, add tag focus-info-collected to the issue so the responsible developers can find and fix it
Setting up “logging.properties”
You should only follow this section if referred from the step 3 of the instruction above.
- Copy “logging.properties” file from any JDK 11 distribution (usually stored under “conf” folder).
- Modify “logging.properties”:
java.util.logging.ConsoleHandler.level = ALL
- Add component to the end (if needed, you can find other components in java.awt.Component - eventLog, focusLog, etc):
java.awt.focus.Component.level = ALL
sun.lwawt.focus.LWComponentPeer.level = ALL
java.awt.focus.DefaultKeyboardFocusManager.level = ALL
For reference, see this link.