Scroll jumps to top in Cursor terminal + PowerShell during streaming/resize
Resolved 💬 4 comments Opened Feb 4, 2026 by sudo-init Closed Mar 5, 2026
Scroll jumps to top in Cursor terminal + PowerShell during streaming/resize
Description
When using Claude Code in Cursor IDE terminal with PowerShell, the terminal scroll position jumps to the top during:
- Response streaming
- Terminal resize
Environment
- IDE: Cursor (VSCode fork)
- Shell: PowerShell
- OS: Windows 11
- Claude Code version: 2.1.31
Environment variables in Cursor terminal:
TERM_PROGRAM=vscode
TERM_PROGRAM_VERSION=2.3.41
WT_SESSION=(empty)
MSYSTEM=(empty)
Root Cause Analysis
After analyzing the bundled cli.js, I found the issue:
1. Terminal detection correctly identifies Cursor as VSCode-compatible
function hd5() {
if (Cd5()) return true; // WT_SESSION check
if (process.platform === "win32" &&
process.env.TERM_PROGRAM === "vscode" &&
process.env.TERM_PROGRAM_VERSION) return true; // ← Cursor matches here
if (Sd5()) return true; // mintty, MSYSTEM
return false;
}
2. This causes \x1B[3J to be used for clearTerminal
function sy1() {
if (process.platform === "win32")
if (hd5())
return Wq6 + G4A + P4A; // \x1B[2J\x1B[3J\x1B[H
else
return Wq6 + yd5;
return Wq6 + G4A + P4A;
}
3. Full reset (clearTerminal) is triggered frequently
render(A, q) {
// Triggered on resize
if (q.viewport.height < A.viewport.height ||
A.viewport.width !== 0 && q.viewport.width !== A.viewport.width)
return E_1(q, "resize", ...); // calls clearTerminal
// Triggered during streaming when height changes
if (w && O && H)
return E_1(q, "offscreen", ...);
// Triggered on scrollback changes
if (firstChangeY >= 0)
return E_1(q, "scrollback changes", ...);
}
4. The \x1B[3J sequence causes scroll jump in Cursor terminal
The \x1B[3J sequence (clear scrollback buffer) appears to cause the viewport to jump to the top in Cursor's terminal emulator.
Suggested Fixes
- Option A: Detect Cursor terminal specifically and avoid
\x1B[3J
- Cursor sets
TERM_PROGRAM=vscodebut may handle\x1B[3Jdifferently than actual VSCode
- Option B: Reduce full reset frequency during streaming
- Expand incremental update coverage to avoid
clearTerminalcalls
- Option C: Use cursor save/restore sequences
- Add
\x1B[s(save) and\x1B[u(restore) around render operations - Currently 0 occurrences of cursor save/restore in the codebase
Related Issues
- #3648 - Terminal Scrolling Uncontrollably
- #14208 - Cursor position drift / scrollback corruption on Windows
- #16774 - Jumping and scrolling issues
- #16939 - Terminal flickering/rapid scrolling on Windows 11
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗