You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何阻止PyCharm切换窗口时自动关闭脚本文件?

Fix for PyCharm CE: Files Closing & Project Tree Collapsing When Switching Windows

Hey there, I’ve run into similar quirky behavior with PyCharm before—let’s walk through some fixes that should get this sorted out for you:

1. Clear PyCharm’s Cache (First Step!)

Corrupted cache is one of the most common culprits for weird UI glitches:

  • Go to File → Invalidate Caches... in the top menu
  • Check the box for Clear file system cache and local history, then click Invalidate and Restart
  • Once PyCharm boots back up, test switching windows again—this often fixes random state-reset issues

2. Rule Out Plugin Conflicts

Third-party plugins can mess with PyCharm’s window state management:

  • Open File → Settings → Plugins
  • Disable all non-JetBrains plugins (look for the ones not marked with the JetBrains logo)
  • Restart PyCharm and see if the problem goes away
  • If it does, re-enable plugins one by one until you find the troublemaker—then update or uninstall it

3. Double-Check Window & Tab Settings

Make sure PyCharm is set to remember your session state:

  • Go to File → Settings → Appearance & Behavior → System Settings
  • Under Window Options, ensure both Restore window on startup and Remember window size and position are checked
  • Next, head to Editor → General → Editor Tabs:
    • Even though you adjusted the tab limit, confirm When tabs exceed limit isn’t set to Close inactive tabs (though this shouldn’t affect single-file cases, it’s worth verifying)

4. Check for System-Level Window Manager Interference

Sometimes external tools mess with how apps retain their state:

  • If you use window management tools (like PowerToys on Windows, Magnet on Mac, or tiling managers on Linux), temporarily disable them
  • Test switching windows again—if the problem stops, you’ll need to adjust that tool’s settings to exclude PyCharm

5. Reset PyCharm’s Configuration (Last Resort)

If nothing else works, a fresh config might be needed:

  • Close PyCharm completely
  • Locate your PyCharm config folder:
    • Windows: C:\Users\<YourUsername>\.PyCharmCE<VersionNumber>
    • Mac: ~/Library/Application Support/JetBrains/PyCharmCE<VersionNumber>
    • Linux: ~/.PyCharmCE<VersionNumber>
  • Rename the folder to something like PyCharmCE<VersionNumber>_backup (so you can restore it if needed)
  • Launch PyCharm again—it’ll create a clean default config
  • Test the window switching behavior; if it works, you can gradually reimport your old settings/plugins

内容的提问来源于stack exchange,提问作者AButkov

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:47:24