Fix iterm alternate buffer mode issue rendering backgrounds (#17634)

This commit is contained in:
Jacob Richman
2026-01-27 05:15:44 -08:00
committed by GitHub
parent 312a72acb8
commit 6b021aa27b
6 changed files with 183 additions and 1 deletions
@@ -20,3 +20,28 @@ export function getColorDepth(): number {
export function isLowColorDepth(): boolean {
return getColorDepth() < 24;
}
let cachedIsITerm2: boolean | undefined;
/**
* Returns true if the current terminal is iTerm2.
*/
export function isITerm2(): boolean {
if (cachedIsITerm2 !== undefined) {
return cachedIsITerm2;
}
cachedIsITerm2 =
process.env['TERM_PROGRAM'] === 'iTerm.app' ||
!!process.env['ITERM_SESSION_ID'];
return cachedIsITerm2;
}
/**
* Resets the cached iTerm2 detection value.
* Primarily used for testing.
*/
export function resetITerm2Cache(): void {
cachedIsITerm2 = undefined;
}