Skip to content

fix: prevent window focus ping-pong between IDEs on Windows - #18

Open
tangcent wants to merge 2 commits into
mainfrom
fix/window-focus-ping-pong
Open

fix: prevent window focus ping-pong between IDEs on Windows#18
tangcent wants to merge 2 commits into
mainfrom
fix/window-focus-ping-pong

Conversation

@tangcent

@tangcent tangcent commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • When two IDE windows (e.g. JetBrains IDEA and VS Code) are actively mirroring each other on Windows, opening the mirrored active file in the unfocused window was stealing OS focus back. This caused an infinite "focus ping-pong" between the two IDE windows.

  • This PR adds window focus checking before activating the mirrored active file:

    • JetBrains: Change openFile(virtualFile, focus) to use the computed windowFocused value instead of always forcing focus. Expose windowFocusedProvider for testability. Add unit tests for both focused/unfocused scenarios.
    • VS Code: Change preserveFocus in showTextDocument to invert based on windowFocused (preserveFocus = !windowFocused). Add unit tests.
  • Also improves jetbrains-plugin/build.gradle.kts build configuration:

    • Disable initializeIntelliJPlugin self-update check (fails frequently due to GitHub network issues on Windows)
    • Skip buildSearchableOptions task (often OOMs on Windows, not needed for a small plugin)
    • Set explicit Java 17 source/target compatibility (required by IntelliJ Platform 2023.3+)
  • Follows project rules: cross-plugin feature parity applied to both JetBrains and VS Code, tests added in both plugins.

When two IDE windows mirror each other, the follower should not steal OS window focus. Introduces windowFocusedProvider/isWindowFocused checks so openFile/showTextDocument preserves focus when the receiving window is not active. Also fixes build.gradle.kts: disable self-update, set Java 17 target, skip buildSearchableOptions.
@tangcent tangcent added the bug Something isn't working label Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant