mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-30 16:39:33 +01:00
fix(web): keep the reader's row when a flush clears scrollback (#814)
- flushPendingWrites falls back to the absolute viewport index when the write disposed the marker, which ESC[3J or RIS also do (the narrow and middle strips keep 3J), instead of sending the reader to row 0. - The live-output mark block moves below the write's try/catch, so the catch only covers the write. - Test: one flush of ESC[H ESC[2J ESC[3J plus a reprint keeps the reader on line 100, with and without markers.
This commit is contained in:
1 parent
a92d512459
commit
e44d586f93
3 files changed
+43
-14
No files matched your search
@@ -4791,30 +4791,33 @@ Object.assign(CodemanApp.prototype, {
|
||||
// signal, which is the earliest point the anchor can actually be
|
||||
// reasserted. (The synchronous version passed its regression test only
|
||||
// because the test's write mock moved the viewport synchronously.)
|
||||
const viewportY = viewportMarker
|
||||
? (viewportMarker.isDisposed ? 0 : viewportMarker.line)
|
||||
: preserveViewportY;
|
||||
// A marker is disposed when its row is trimmed off a full scrollback,
|
||||
// but also when the stream itself erases scrollback (`ESC[3J`, RIS),
|
||||
// which the narrow and middle strips keep. Fall back to the absolute
|
||||
// index then, as before markers, rather than sending the reader to row 0.
|
||||
const viewportY = viewportMarker && !viewportMarker.isDisposed ? viewportMarker.line : preserveViewportY;
|
||||
viewportMarker?.dispose();
|
||||
this._restoreTerminalViewport(viewportY, flushSessionId);
|
||||
this._scheduleTerminalWriteFlush();
|
||||
this._noteMobileImeAuthoritativeOutput(flushedOutputSeq, flushSessionId);
|
||||
});
|
||||
// Only live writes can open a new tmux repaint gap; replays cannot (#814).
|
||||
if (writeChunk.length && flushSessionId && !this._isLoadingBuffer) {
|
||||
const marked = (this._liveOutputSinceFullPull ||= new Set());
|
||||
const newlyMarked = !marked.has(flushSessionId);
|
||||
marked.add(flushSessionId);
|
||||
const generations = (this._liveOutputGen ||= new Map());
|
||||
generations.set(flushSessionId, (generations.get(flushSessionId) || 0) + 1);
|
||||
// Mark transitions sync immediately; onScroll is coalesced on all devices.
|
||||
if (newlyMarked) this._syncHistoryReloadAction?.();
|
||||
}
|
||||
} catch (err) {
|
||||
viewportMarker?.dispose();
|
||||
this._terminalWriteInFlight = false;
|
||||
this._terminalWriteInFlightBytes = 0;
|
||||
throw err;
|
||||
}
|
||||
// Only live writes can open a new tmux repaint gap; replays cannot (#814).
|
||||
// Outside the try: the catch above must only cover the write itself.
|
||||
if (writeChunk.length && flushSessionId && !this._isLoadingBuffer) {
|
||||
const marked = (this._liveOutputSinceFullPull ||= new Set());
|
||||
const newlyMarked = !marked.has(flushSessionId);
|
||||
marked.add(flushSessionId);
|
||||
const generations = (this._liveOutputGen ||= new Map());
|
||||
generations.set(flushSessionId, (generations.get(flushSessionId) || 0) + 1);
|
||||
// Mark transitions sync immediately; onScroll is coalesced on all devices.
|
||||
if (newlyMarked) this._syncHistoryReloadAction?.();
|
||||
}
|
||||
const bytesThisFrame = deferred ? MAX_FRAME_BYTES : _joinedLen;
|
||||
const _dt = performance.now() - _t0;
|
||||
if (_dt > 100 || deferred)
|
||||
|
||||
Reference in new issue
Block a user