mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
Compare commits
38
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e49c72519f | ||
|
|
d8480d3614 | ||
|
|
f62a1e5c8b | ||
|
|
c325fe132f | ||
|
|
c34780478b | ||
|
|
8678c45f9f | ||
|
|
99a02e3376 | ||
|
|
0c3de8734f | ||
|
|
1462284bd3 | ||
|
|
d77f837475 | ||
|
|
7788fbf2ee | ||
|
|
8d7277057d | ||
|
|
fe696df26f | ||
|
|
0940f4ee2b | ||
|
|
b57c870f24 | ||
|
|
8d173d8dd6 | ||
|
|
0ba0ddae24 | ||
|
|
797cf597bd | ||
|
|
d8b2ff7384 | ||
|
|
6e99f74cc7 | ||
|
|
a6af7f6ac4 | ||
|
|
d82ad03ba9 | ||
|
|
b82bc038bb | ||
|
|
cf4d0722de | ||
|
|
5f4a8d8ae1 | ||
|
|
6705286d79 | ||
|
|
29c97d4168 | ||
|
|
c3f03b4776 | ||
|
|
69f79f0a07 | ||
|
|
7fb3445064 | ||
|
|
0ddd313533 | ||
|
|
ea1f113d8b | ||
|
|
98cf6276ed | ||
|
|
2bef7a4bc0 | ||
|
|
1b224f8a3c | ||
|
|
0d7a0b1aea | ||
|
|
8a1a190aee | ||
|
|
0341e7ddbf |
No files matched your search
+127
-1
@@ -1,5 +1,7 @@
|
||||
import { createTerminalReflowReadingPosition } from "./terminal/terminalReflowReadingPosition";
|
||||
import { resolveHostOs } from '../domain/host';
|
||||
import { Terminal as XTerm } from "@xterm/xterm";
|
||||
import type { IMarker } from "@xterm/xterm";
|
||||
import { FitAddon } from "@xterm/addon-fit";
|
||||
import { SerializeAddon } from "@xterm/addon-serialize";
|
||||
import { SearchAddon } from "@xterm/addon-search";
|
||||
@@ -255,6 +257,7 @@ import {
|
||||
import {
|
||||
alignTerminalViewportScroll,
|
||||
createSynchronizedOutputFitScheduler,
|
||||
resolveTerminalReflowScrollAnchor,
|
||||
AUTO_RUN_SNIPPET_LINE_DELAY_MS,
|
||||
forceSyncRenderAfterResize,
|
||||
MAX_CONNECTION_LOG_DATA_CHARS,
|
||||
@@ -642,6 +645,7 @@ const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
const isRendererActiveRef = useRef(isRendererActive);
|
||||
isRendererActiveRef.current = isRendererActive;
|
||||
const pendingOutputScrollRef = useRef(false);
|
||||
const reflowReadingPositionRef = useRef(createTerminalReflowReadingPosition());
|
||||
const lastFittedSizeRef = useRef<{ width: number; height: number } | null>(null);
|
||||
const fontWeightFixupDoneRef = useRef(false);
|
||||
|
||||
@@ -3009,6 +3013,48 @@ const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
const dimensions = fitAddon.proposeDimensions();
|
||||
if (!dimensions || Number.isNaN(dimensions.cols) || Number.isNaN(dimensions.rows)) return;
|
||||
|
||||
// A column change rewraps the scrollback, moving rows above the
|
||||
// reading position, so a saved row index no longer points at the same
|
||||
// content after the resize. Capture the content instead of an index.
|
||||
// Row-only and pixel-only fits never rewrap, so skip the O(scrollback)
|
||||
// anchor scan on those frames.
|
||||
const previousCols = term.cols;
|
||||
const reflowAnchor = wasPinnedToBottom || term.cols === dimensions.cols
|
||||
? null
|
||||
: reflowReadingPositionRef.current.capture(buffer, {
|
||||
// xterm keeps at most rows + scrollback buffer rows and trims
|
||||
// from the top beyond that (Buffer._getCorrectBufferLength), so
|
||||
// these bounds let the capture skip its whole-line measurement
|
||||
// when no trim can reach the anchored line.
|
||||
maxRows: dimensions.rows + (term.options.scrollback ?? 1000),
|
||||
oldCols: previousCols,
|
||||
newCols: dimensions.cols,
|
||||
});
|
||||
|
||||
// Markers pinned to the viewed row and to the viewed logical line's
|
||||
// start. xterm adjusts marker rows through the rewrap (and disposes
|
||||
// them when their row is deleted or trimmed), so after the resize a
|
||||
// surviving marker marks where the viewed content moved without
|
||||
// scanning for it. Each rewrap direction deletes a different row:
|
||||
// a column grow merges a wrapped continuation into its predecessor
|
||||
// (disposing a marker on the viewed continuation row), while a column
|
||||
// shrink on a full scrollback trims the line's first physical rows
|
||||
// (disposing a marker on the start row; the viewed content survives).
|
||||
// Pinning one marker to each of those rows keeps the resolver seeded
|
||||
// in both directions.
|
||||
let reflowMarker: IMarker | null = null;
|
||||
let reflowStartMarker: IMarker | null = null;
|
||||
if (reflowAnchor) {
|
||||
reflowMarker = term.registerMarker(
|
||||
savedViewportY - (buffer.baseY + buffer.cursorY),
|
||||
);
|
||||
if (reflowAnchor.startRow !== savedViewportY) {
|
||||
reflowStartMarker = term.registerMarker(
|
||||
reflowAnchor.startRow - (buffer.baseY + buffer.cursorY),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
lastFittedSizeRef.current = { width, height };
|
||||
// addon-fit 0.11 clears the renderer before resizing, which can show
|
||||
// as a one-frame WebGL blink during layout changes. Resize directly
|
||||
@@ -3030,15 +3076,95 @@ const TerminalComponent: React.FC<TerminalProps> = ({
|
||||
// Align first so the relative restore below does not apply that delta twice.
|
||||
alignTerminalViewportScroll(term);
|
||||
|
||||
let anchoredViewportY: number | null = null;
|
||||
// Preserve scroll position across resize (superset/Tabby pattern).
|
||||
if (wasPinnedToBottom) {
|
||||
term.scrollToBottom();
|
||||
} else {
|
||||
const targetY = Math.min(savedViewportY, term.buffer.active.baseY);
|
||||
// Re-locate the anchored content; fall back to the saved row index
|
||||
// when the anchored content is gone (scrollback trim). Prefer the
|
||||
// viewport-row marker (it marks the viewed row itself) over the
|
||||
// line-start marker, which only seeds the scan.
|
||||
const viewedMarkerRow = reflowMarker && !reflowMarker.isDisposed && reflowMarker.line >= 0
|
||||
? reflowMarker.line
|
||||
: null;
|
||||
const startMarkerRow = reflowStartMarker && !reflowStartMarker.isDisposed
|
||||
&& reflowStartMarker.line >= 0
|
||||
? reflowStartMarker.line
|
||||
: null;
|
||||
const markerRow = viewedMarkerRow ?? startMarkerRow;
|
||||
reflowMarker?.dispose();
|
||||
reflowMarker = null;
|
||||
reflowStartMarker?.dispose();
|
||||
reflowStartMarker = null;
|
||||
// A continuation anchor registers both markers, so both coming back
|
||||
// disposed means the trim deleted the rows they pin — but marker
|
||||
// disposal alone is not proof the anchored content is gone: a
|
||||
// narrowing rewrap relocates the viewed characters into newly
|
||||
// appended continuation rows before the trim cuts the same number
|
||||
// of rows from the top, so the characters can survive at the buffer
|
||||
// top while both pinned rows are gone. `trimReachedStart` switches
|
||||
// the resolver to that remnant check (a trim removes from the top,
|
||||
// so a line whose start row it reached leaves any surviving part at
|
||||
// row 0) instead of letting it sweep the stale row for repetitive
|
||||
// duplicates on every divider-drag frame. A single disposed
|
||||
// viewport marker keeps the seeded resolve: a column-grow merge
|
||||
// disposes it while the merged line still matches the anchor.
|
||||
const trimReachedStart = reflowAnchor !== null
|
||||
&& reflowAnchor.startRow !== savedViewportY
|
||||
&& viewedMarkerRow === null
|
||||
&& startMarkerRow === null;
|
||||
anchoredViewportY = reflowAnchor === null
|
||||
? null
|
||||
: resolveTerminalReflowScrollAnchor(
|
||||
term.buffer.active,
|
||||
reflowAnchor,
|
||||
markerRow,
|
||||
trimReachedStart,
|
||||
);
|
||||
// Content matching can still fail when the viewed line is the
|
||||
// cursor's own logical line: with the pinned `reflowCursorLine:
|
||||
// false` default a narrowing resize skips rewrapping that line and
|
||||
// truncates its rows, so the captured prefix no longer matches even
|
||||
// though the viewport-row marker survived and tracks the exact
|
||||
// viewed row. Restore the marker position there rather than the
|
||||
// stale saved index, which would jump upward by the accumulated
|
||||
// reflow delta of the rewrapped lines above. (The line-start marker
|
||||
// must not stand in for a failed match: its row only seeds the
|
||||
// scan, and the column-grow merge disposes the viewport marker
|
||||
// while the merged line still matches the anchor.)
|
||||
// Only those two cases may trust the viewport-row marker. When the
|
||||
// viewport sits partway into a wrapped non-cursor line, a column
|
||||
// shrink rewraps that line and xterm appends the group's newly
|
||||
// created rows after the existing ones, so the marker keeps its old
|
||||
// within-line row while the viewed characters move deeper — even
|
||||
// though xterm still adjusts the marker through unrelated
|
||||
// insertions and would have disposed it only if its row were
|
||||
// trimmed. That mismatch is unobservable through marker disposal,
|
||||
// so trust the marker as a restore position only when the anchored
|
||||
// line is the cursor's own (row indices survive truncation) or the
|
||||
// marker sits at the anchored line's start (the group's new rows
|
||||
// are appended below it, and insertions above shift it onto the
|
||||
// relocated start). Anything else falls back to the plain row
|
||||
// restore.
|
||||
const markerTrackedViewport = reflowAnchor !== null
|
||||
&& (reflowAnchor.startRow === savedViewportY
|
||||
|| reflowAnchor.containsCursor === true)
|
||||
? viewedMarkerRow
|
||||
: null;
|
||||
const targetY = Math.min(
|
||||
anchoredViewportY ?? markerTrackedViewport ?? savedViewportY,
|
||||
term.buffer.active.baseY,
|
||||
);
|
||||
if (term.buffer.active.viewportY !== targetY) {
|
||||
term.scrollToLine(targetY);
|
||||
}
|
||||
}
|
||||
if (term.cols !== previousCols) {
|
||||
reflowReadingPositionRef.current.remember(
|
||||
term.buffer.active, anchoredViewportY === null ? null : reflowAnchor,
|
||||
);
|
||||
}
|
||||
term.refresh(0, Math.max(0, term.rows - 1));
|
||||
|
||||
if (typeof requestAnimationFrame === "function") {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,55 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import { test } from 'node:test';
|
||||
import { createTerminalReflowReadingPosition } from './terminalReflowReadingPosition';
|
||||
import { resolveTerminalReflowScrollAnchor } from './terminalHelpers';
|
||||
|
||||
function fixture() {
|
||||
let cols = 80;
|
||||
let text = Array.from({ length: 1000 }, (_, i) => String(i).padStart(4, '0') + ' ').join('');
|
||||
const buffer = {
|
||||
viewportY: 30,
|
||||
get length() { return Math.ceil(text.length / cols) + 30; },
|
||||
get baseY() { return this.length - 25; },
|
||||
getLine(row: number) {
|
||||
const count = Math.ceil(text.length / cols);
|
||||
if (row >= this.length) return undefined;
|
||||
return {
|
||||
isWrapped: row > 0 && row < count,
|
||||
translateToString: () => row < count ? text.slice(row * cols, (row + 1) * cols) : `follower ${row - count}`,
|
||||
};
|
||||
},
|
||||
};
|
||||
const tracker = createTerminalReflowReadingPosition();
|
||||
return {
|
||||
buffer,
|
||||
changeText() { text = text.replace('0480', 'EDIT'); },
|
||||
fit(nextCols: number) {
|
||||
const anchor = tracker.capture(buffer, { oldCols: cols, newCols: nextCols, maxRows: 1030 });
|
||||
cols = nextCols;
|
||||
const row = anchor ? resolveTerminalReflowScrollAnchor(buffer, anchor, 0) : null;
|
||||
if (row !== null) buffer.viewportY = row;
|
||||
tracker.remember(buffer, row === null ? null : anchor);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test('continuous shrink and grow retain the original character within the top row', () => {
|
||||
const f = fixture();
|
||||
for (const cols of [...Array.from({ length: 40 }, (_, i) => 79 - i), ...Array.from({ length: 40 }, (_, i) => 41 + i)]) {
|
||||
f.fit(cols);
|
||||
assert.equal(f.buffer.viewportY, Math.floor(2400 / cols));
|
||||
}
|
||||
});
|
||||
|
||||
test('user scroll and changed visible output establish a new reading position', () => {
|
||||
const f = fixture();
|
||||
f.fit(79);
|
||||
f.buffer.viewportY = 20;
|
||||
f.fit(78);
|
||||
assert.equal(f.buffer.viewportY, Math.floor(20 * 79 / 78));
|
||||
const g = fixture();
|
||||
g.fit(79);
|
||||
g.changeText();
|
||||
g.fit(78);
|
||||
assert.equal(g.buffer.viewportY, Math.floor(30 * 79 / 78));
|
||||
});
|
||||
@@ -0,0 +1,51 @@
|
||||
import { captureTerminalReflowScrollAnchor } from './terminalHelpers';
|
||||
import type { TerminalReflowScrollAnchor } from './terminalHelpers';
|
||||
|
||||
type Buffer = Parameters<typeof captureTerminalReflowScrollAnchor>[0];
|
||||
|
||||
/** Keep the character within the top row across consecutive resize frames. */
|
||||
export function createTerminalReflowReadingPosition() {
|
||||
let previous: {
|
||||
buffer: Buffer;
|
||||
viewportY: number;
|
||||
anchor: TerminalReflowScrollAnchor;
|
||||
remainder: number;
|
||||
} | null = null;
|
||||
|
||||
return {
|
||||
capture(buffer: Buffer, limits: Parameters<typeof captureTerminalReflowScrollAnchor>[1]) {
|
||||
const anchor = captureTerminalReflowScrollAnchor(buffer, limits);
|
||||
const saved = previous;
|
||||
previous = null;
|
||||
if (!anchor || anchor.containsCursor) return anchor;
|
||||
// A user scroll or changed output establishes a new reading position.
|
||||
if (saved?.buffer === buffer && saved.viewportY === buffer.viewportY
|
||||
&& saved.anchor.startRow === anchor.startRow
|
||||
&& saved.anchor.charOffset === anchor.charOffset
|
||||
&& saved.anchor.textPrefix === anchor.textPrefix
|
||||
&& saved.anchor.viewedText === anchor.viewedText
|
||||
&& saved.anchor.contextSuffix === anchor.contextSuffix) {
|
||||
anchor.charOffset += saved.remainder;
|
||||
anchor.viewedText = anchor.viewedText?.slice(saved.remainder);
|
||||
}
|
||||
return anchor;
|
||||
},
|
||||
// The caller passes null unless content resolution succeeded. A cursor
|
||||
// follower may change during resize; the resolver already validates that
|
||||
// tolerance. Save its new identity for the next pre-fit comparison.
|
||||
remember(buffer: Buffer, anchor: TerminalReflowScrollAnchor | null) {
|
||||
previous = null;
|
||||
if (!anchor || anchor.containsCursor) return;
|
||||
const current = captureTerminalReflowScrollAnchor(buffer, {
|
||||
maxRows: Number.MAX_SAFE_INTEGER, oldCols: 1, newCols: 1,
|
||||
});
|
||||
// Trim, clamping and failed content resolution must not carry a stale
|
||||
// offset into the next frame. Only retain the sub-row rounding loss.
|
||||
if (!current || current.containsCursor || current.textPrefix !== anchor.textPrefix) return;
|
||||
const remainder = anchor.charOffset - current.charOffset;
|
||||
const rowLength = buffer.getLine(buffer.viewportY)?.translateToString(false).length ?? 0;
|
||||
if (remainder < 0 || remainder >= rowLength) return;
|
||||
previous = { buffer, viewportY: buffer.viewportY, anchor: current, remainder };
|
||||
},
|
||||
};
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -21,7 +21,7 @@ if (!process.versions.electron) {
|
||||
const safeFitSource = esbuild.transformSync(source.slice(start, end), { loader: "ts" }).code;
|
||||
const bundle = esbuild.buildSync({
|
||||
stdin: {
|
||||
contents: 'export {Terminal} from "@xterm/xterm"; export {alignTerminalViewportScroll, forceSyncRenderAfterResize, createSynchronizedOutputFitScheduler} from "./components/terminal/terminalHelpers";',
|
||||
contents: 'export {Terminal} from "@xterm/xterm"; export {alignTerminalViewportScroll, captureTerminalReflowScrollAnchor, forceSyncRenderAfterResize, createSynchronizedOutputFitScheduler, resolveTerminalReflowScrollAnchor} from "./components/terminal/terminalHelpers"; export {createTerminalReflowReadingPosition} from "./components/terminal/terminalReflowReadingPosition";',
|
||||
loader: "ts", resolveDir: root,
|
||||
},
|
||||
bundle: true, format: "cjs", platform: "browser", write: false,
|
||||
@@ -44,7 +44,7 @@ if (!process.versions.electron) {
|
||||
const assert = require('node:assert/strict');
|
||||
const loaded = {exports:{}};
|
||||
((module,exports)=>{${bundle}})(loaded,loaded.exports);
|
||||
const {Terminal,forceSyncRenderAfterResize,createSynchronizedOutputFitScheduler} = loaded.exports;
|
||||
const {createTerminalReflowReadingPosition,Terminal,forceSyncRenderAfterResize,createSynchronizedOutputFitScheduler,captureTerminalReflowScrollAnchor,resolveTerminalReflowScrollAnchor} = loaded.exports;
|
||||
const alignTerminalViewportScroll = process.env.NETCATTY_FIT_BASELINE ? ()=>{} : loaded.exports.alignTerminalViewportScroll;
|
||||
const wait = ms => new Promise(resolve=>setTimeout(resolve,ms));
|
||||
const term = new Terminal({cols:80,rows:25,scrollback:1000,fontSize:14,allowProposedApi:true,smoothScrollDuration:0});
|
||||
@@ -52,6 +52,7 @@ if (!process.versions.electron) {
|
||||
el.style.cssText='width:900px;height:560px'; term.open(el);
|
||||
const write = data => new Promise(resolve=>term.write(data,resolve));
|
||||
const ref = current => ({current});
|
||||
const reflowReadingPositionRef=ref(createTerminalReflowReadingPosition());
|
||||
const termRef=ref(term), containerRef=ref(el), isRendererActiveRef=ref(true), lastFittedSizeRef=ref(null);
|
||||
const autocompleteRepositionRef=ref(null), xtermRuntimeRef=ref(null), pendingWriteSafeFitRef=ref(null);
|
||||
const synchronizedFitSchedulerRef=ref(createSynchronizedOutputFitScheduler());
|
||||
@@ -68,11 +69,67 @@ if (!process.versions.electron) {
|
||||
assert.equal(term.buffer.active.viewportY,expected,label+' buffer');
|
||||
assert.ok(Math.abs(domRow()-expected)<0.01,label+' DOM expected '+expected+' actual '+domRow());
|
||||
};
|
||||
// Content helpers: a column rewrap moves reading content to a different
|
||||
// row index, so assertions track characters rather than row numbers.
|
||||
const joinFrom=(row)=>{
|
||||
const b=term.buffer.active;
|
||||
let text=''; let r=Math.max(0,Math.min(row,b.length-1));
|
||||
for(;r<b.length&&text.length<64;r++){
|
||||
const l=b.getLine(r);
|
||||
if(!l) break;
|
||||
if(text.length>0&&!l.isWrapped) break;
|
||||
text+=l.translateToString(true);
|
||||
}
|
||||
return text;
|
||||
};
|
||||
const logicalJoinFrom=(row)=>{
|
||||
const b=term.buffer.active;
|
||||
let s=Math.max(0,Math.min(row,b.length-1));
|
||||
while(s>0&&b.getLine(s)?.isWrapped) s--;
|
||||
return joinFrom(s);
|
||||
};
|
||||
const expectReadingContent=(chars,label)=>{
|
||||
const actual=logicalJoinFrom(term.buffer.active.viewportY);
|
||||
assert.ok(actual.includes(chars),label+' expected '+JSON.stringify(chars)+' in '+JSON.stringify(actual.slice(0,40)));
|
||||
};
|
||||
// A long wrapped paragraph must retain its character offset, not just
|
||||
// its logical-line identity, throughout a continuous divider drag.
|
||||
const longText=Array.from({length:1000},(_,i)=>String(i).padStart(4,'0')+' ').join('');
|
||||
await write(longText+'\\r\\n'+Array.from({length:30},(_,i)=>'follower '+i).join('\\r\\n'));
|
||||
await wait(100);term.scrollToLine(30);await wait(50);
|
||||
const readingOffset=30*80;
|
||||
const checkOffset=(offset,label)=>{
|
||||
const row=term.buffer.active.viewportY;
|
||||
assert.ok(row*term.cols<=offset && (row+1)*term.cols>offset,label+' row '+row+' cols '+term.cols);
|
||||
check(row,label);
|
||||
};
|
||||
for(let cols=79;cols>=40;cols--){fit(cols,25);await wait(10);checkOffset(readingOffset,'long paragraph shrink');}
|
||||
for(let cols=41;cols<=80;cols++){fit(cols,25);await wait(10);checkOffset(readingOffset,'long paragraph grow');}
|
||||
// Scrolling establishes a fresh anchor instead of restoring the old one.
|
||||
term.scrollLines(-10);await wait(50);
|
||||
const userOffset=term.buffer.active.viewportY*term.cols;
|
||||
for(let cols=79;cols>=40;cols--){fit(cols,25);await wait(10);checkOffset(userOffset,'user scroll during drag');}
|
||||
term.reset();fit(80,25);await wait(50);
|
||||
// The cursor's own wrapped line is truncated/padded by xterm instead
|
||||
// of reflowed. Its changing text must not reset the paragraph offset.
|
||||
await write(longText+'\\r\\n'+'cursor '.repeat(30));
|
||||
await wait(100);term.scrollToLine(30);await wait(50);
|
||||
for(let cols=79;cols>=40;cols--){fit(cols,25);await wait(10);checkOffset(readingOffset,'cursor follower shrink');}
|
||||
for(let cols=41;cols<=80;cols++){fit(cols,25);await wait(10);checkOffset(readingOffset,'cursor follower grow');}
|
||||
term.reset();fit(80,25);await wait(50);
|
||||
|
||||
await write(Array.from({length:200},(_,i)=>'line '+i+' '+('A B repeated '.repeat(7))).join('\\r\\n'));
|
||||
await wait(100); term.scrollToLine(70); await wait(50);
|
||||
fit(80,16); await wait(80); check(70,'shrink');
|
||||
fit(80,30); await wait(80); check(70,'grow');
|
||||
for(let rows=29;rows>=12;rows--){fit(80,rows);await wait(20);check(70,'drag '+rows);}
|
||||
// Column changes rewrap the scrollback: the row index of the reading
|
||||
// content shifts, so the anchor must re-locate the characters (#3299).
|
||||
const colsDragChars = joinFrom(term.buffer.active.viewportY).slice(0,24);
|
||||
for(let cols=80;cols>=52;cols--){fit(cols,18);await wait(10);}
|
||||
expectReadingContent(colsDragChars,'cols shrink keeps reading chars');
|
||||
for(let cols=52;cols<=80;cols++){fit(cols,18);await wait(10);}
|
||||
expectReadingContent(colsDragChars,'cols grow keeps reading chars');
|
||||
term.scrollToBottom();await wait(50);fit(80,8);await wait(80);check(term.buffer.active.baseY,'pinned shrink');
|
||||
term.scrollLines(-1);await wait(50);check(term.buffer.active.baseY-1,'first scroll after shrink');
|
||||
term.scrollToLine(70);await wait(50);
|
||||
@@ -80,19 +137,26 @@ if (!process.versions.electron) {
|
||||
await write('\\x1b[?2026h');fit(100,20);fit(120,24);await wait(80);
|
||||
assert.deepEqual([term.cols,term.rows],oldSize,'no reflow inside synchronized frame');
|
||||
term.scrollLines(-3);await wait(40);const selected=term.buffer.active.viewportY;
|
||||
const selectedChars = joinFrom(selected).slice(0,24);
|
||||
await write('\\x1b[?2026l');await wait(120);
|
||||
assert.deepEqual([term.cols,term.rows],[120,24]);check(Math.min(selected,term.buffer.active.baseY),'user selected position');
|
||||
assert.deepEqual([term.cols,term.rows],[120,24]);
|
||||
expectReadingContent(selectedChars,'user selected position');
|
||||
const reentryChars = logicalJoinFrom(term.buffer.active.viewportY).slice(0,24);
|
||||
await write('\\x1b[?2026h');fit(90,18);await write('\\x1b[?2026l\\x1b[?2026h');await wait(70);
|
||||
assert.equal(term.cols,120,'a new synchronized frame delays retry');
|
||||
await write('\\x1b[?2026l');await wait(100);check(Math.min(selected,term.buffer.active.baseY),'mode reentry');
|
||||
await write('\\x1b[?2026l');await wait(100);
|
||||
expectReadingContent(reentryChars,'mode reentry');
|
||||
await write('\\r\\n'+Array.from({length:1200},()=> 'A B repeated').join('\\r\\n'));
|
||||
await wait(80);term.scrollToLine(100);await wait(30);
|
||||
await write('\\x1b[?2026h');fit(130,22);await write('\\r\\n'.repeat(5));
|
||||
const afterTrim=term.buffer.active.viewportY;
|
||||
await write('\\x1b[?2026l');await wait(100);check(afterTrim,'scrollback trim');
|
||||
const trimChars = logicalJoinFrom(afterTrim).slice(0,24);
|
||||
await write('\\x1b[?2026l');await wait(100);
|
||||
expectReadingContent(trimChars,'scrollback trim');
|
||||
const altTripChars = logicalJoinFrom(term.buffer.active.viewportY).slice(0,24);
|
||||
await write('\\x1b[?2026h\\x1b[?1049h');fit(100,20);
|
||||
await write('alternate output\\x1b[?1049l\\x1b[?2026l');await wait(100);
|
||||
check(Math.min(afterTrim,term.buffer.active.baseY),'alternate buffer round trip');
|
||||
expectReadingContent(altTripChars,'alternate buffer round trip');
|
||||
await write('\\x1b[?2026h');fit(110,21);await wait(1400);
|
||||
assert.equal(term.modes.synchronizedOutputMode,false,'xterm timeout releases output');
|
||||
assert.equal(term.cols,110,'fit retried after output timeout');
|
||||
@@ -100,7 +164,7 @@ if (!process.versions.electron) {
|
||||
await write('\\x1b[?2026h');fit(140,25);synchronizedFitSchedulerRef.current.dispose();
|
||||
await write('\\x1b[?2026l');await wait(100);assert.equal(term.cols,beforeDispose,'teardown cancels retry');
|
||||
assert.ok(el.querySelector('.xterm-screen').getBoundingClientRect().height > 0,'real rendered terminal');
|
||||
return {passed:['shrink','grow','18 drag steps','bottom and next scroll','synchronized repeated spaced text','user scroll','mode reentry','full scrollback trim','alternate buffer','output timeout','cleanup'],viewportY:term.buffer.active.viewportY,domRow:domRow()};
|
||||
return {passed:['shrink','grow','18 drag steps','long paragraph character offset and user scroll','cursor follower changes','bottom and next scroll','synchronized repeated spaced text','user scroll','mode reentry','full scrollback trim','alternate buffer','output timeout','cleanup'],viewportY:term.buffer.active.viewportY,domRow:domRow()};
|
||||
})()`);
|
||||
console.log(JSON.stringify(result));
|
||||
if (process.env.NETCATTY_FIT_SCREENSHOT) {
|
||||
|
||||
Reference in new issue
Block a user