| 112 | // Synchronous version that returns cached result or falls back to env.terminal |
| 113 | // Used for backward compatibility - callers should migrate to async version |
| 114 | export function getTerminalWithJetBrainsDetection(): string | null { |
| 115 | // Check for JetBrains terminal on Linux/Windows |
| 116 | if (process.env.TERMINAL_EMULATOR === 'JetBrains-JediTerm') { |
| 117 | // For macOS, bundle ID detection above already handles JetBrains IDEs |
| 118 | if (env.platform !== 'darwin') { |
| 119 | // Return cached value if available, otherwise fall back to generic detection |
| 120 | // The async version should be called early in app initialization to populate cache |
| 121 | if (jetBrainsIDECache !== undefined) { |
| 122 | return jetBrainsIDECache || 'pycharm' |
| 123 | } |
| 124 | // Fall back to generic 'pycharm' if cache not populated yet |
| 125 | return 'pycharm' |
| 126 | } |
| 127 | } |
| 128 | return env.terminal |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Initialize JetBrains IDE detection asynchronously. |