Skip to content

Commit a1c4f2f

Browse files
committed
fire scrollEmitter and preserve scrollbar on new content
1 parent 9606b0e commit a1c4f2f

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

lib/terminal.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,7 @@ export class Terminal implements ITerminalCore {
562562
// bump viewportY by the same amount to keep the viewport locked on
563563
// the same content.
564564
const savedViewportY = this.viewportY;
565-
const savedScrollback = savedViewportY > 0
566-
? this.wasmTerm!.getScrollbackLength() : 0;
565+
const savedScrollback = savedViewportY > 0 ? this.wasmTerm!.getScrollbackLength() : 0;
567566

568567
// Write directly to WASM terminal (handles VT parsing internally)
569568
this.wasmTerm!.write(data);
@@ -590,7 +589,12 @@ export class Terminal implements ITerminalCore {
590589
if (savedViewportY > 0) {
591590
const newScrollback = this.wasmTerm!.getScrollbackLength();
592591
const delta = newScrollback - savedScrollback;
593-
this.viewportY = Math.min(savedViewportY + Math.max(0, delta), newScrollback);
592+
const newViewportY = Math.max(0, Math.min(savedViewportY + delta, newScrollback));
593+
if (newViewportY !== savedViewportY) {
594+
this.viewportY = newViewportY;
595+
this.scrollEmitter.fire(this.viewportY);
596+
if (newScrollback > 0) this.showScrollbar();
597+
}
594598
}
595599

596600
// Check for title changes (OSC 0, 1, 2 sequences)

0 commit comments

Comments
 (0)