Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions packages/shared/src/terminalOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,14 @@ export function terminalOutputResumeText(state: TerminalOutputState): string {
const { screen } = state;
const lastRow = screen.lines.length - 1;
// Moves are relative to the last line, and a viewer only holds the lines in `text`.
const shownLines = state.text.split("\n").length;
const reachable = Math.min(LIVE_LINES, shownLines) - 1;
let reachable = 0;
let cursor = 0;
while (reachable < LIVE_LINES - 1) {
const newline = state.text.indexOf("\n", cursor);
if (newline === -1) break;
reachable += 1;
cursor = newline + 1;
}
const up = (row: number) => Math.min(lastRow - row, reachable);
const goTo = (row: number, col: number) =>
(up(row) > 0 ? `${ESC}[${up(row)}A` : "") + `${ESC}[${col + 1}G`;
Expand Down
Loading