mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-14 10:39:32 +01:00
fix(terminal): a mouse wheel notch pages the CLI's transcript at once
This commit is contained in:
1 parent
002de32a08
commit
81beec7b5b
4 files changed
+94
-19
No files matched your search
@@ -706,6 +706,54 @@ describe('pageKeysForGesture, the pure gesture rules both panes share', () => {
|
||||
expect(steps.map((s) => s.keys).join('')).toBe(UP);
|
||||
});
|
||||
|
||||
it('pages a mouse notch at once (4 rows Chrome, 3 rows Firefox) and repays it over the notches that follow', () => {
|
||||
// Before this, the first 5 Chrome notches (7 Firefox) sent nothing at all: a gesture of a few notches
|
||||
// looked dead. Each page now comes with the notch that opens it instead of the one that completes it:
|
||||
// the rate is the same, one page per 19 rows of travel, a page ahead.
|
||||
const notches = (lines: number, count: number) =>
|
||||
run(
|
||||
Array.from({ length: count }, (_, i) => [lines, i * 400] as [number, number]),
|
||||
38
|
||||
);
|
||||
// Chrome: a page at notch 1, repaid by notches 2 to 5, and the next gesture opens at notch 6.
|
||||
expect(notches(-4, 11).map((s) => s.keys)).toEqual([UP, '', '', '', '', UP, '', '', '', '', UP]);
|
||||
// Firefox's 3-row notches repay it over notches 2 to 7, so the next page opens at notch 8.
|
||||
expect(notches(-3, 8).map((s) => s.keys)).toEqual([UP, '', '', '', '', '', '', UP]);
|
||||
});
|
||||
|
||||
it('keeps a notch debt across slow pauses (up to PAGE_KEY_NOTCH_DEBT_MS), then pages the next notch at once', () => {
|
||||
const { PAGE_KEY_NOTCH_DEBT_MS } = loadTerminalUiHarness().windowRef.CodemanTerminalInput;
|
||||
expect(PAGE_KEY_NOTCH_DEBT_MS).toBe(3000);
|
||||
// Notches 1.2 s apart (past the old second of debt) still add up to one page, not one each.
|
||||
const slow = run(
|
||||
Array.from({ length: 5 }, (_, i) => [-4, i * 1200] as [number, number]),
|
||||
38
|
||||
);
|
||||
expect(slow.map((s) => s.keys)).toEqual([UP, '', '', '', '']);
|
||||
// After more than that of quiet it is a new gesture: its first notch pages at once.
|
||||
const resumed = run(
|
||||
[
|
||||
[-4, 0],
|
||||
[-4, 400],
|
||||
[-4, 4_000],
|
||||
],
|
||||
38
|
||||
);
|
||||
expect(resumed.map((s) => s.keys)).toEqual([UP, '', UP]);
|
||||
});
|
||||
|
||||
it('drops a notch debt when the direction reverses, so a notch back pages too', () => {
|
||||
const steps = run(
|
||||
[
|
||||
[-4, 0],
|
||||
[-4, 400],
|
||||
[4, 800],
|
||||
],
|
||||
38
|
||||
);
|
||||
expect(steps.map((s) => s.keys)).toEqual([UP, '', DOWN]);
|
||||
});
|
||||
|
||||
it('keeps a same-direction pre-paid debt for PAGE_KEY_DEBT_MS, then drops it with its gesture', () => {
|
||||
const { PAGE_KEY_DEBT_MS } = loadTerminalUiHarness().windowRef.CodemanTerminalInput;
|
||||
expect(PAGE_KEY_DEBT_MS).toBe(1000);
|
||||
@@ -1056,11 +1104,12 @@ describe('consistent scroll gesture adapters', () => {
|
||||
expect(app._wheelTickGesture.pending).toBeCloseTo(-0.8);
|
||||
});
|
||||
|
||||
it('preserves accumulated coarse Codex wheel fallback travel', () => {
|
||||
it('pages a coarse Codex wheel notch at once and keeps the travel after it as repayment', () => {
|
||||
const { app, sent } = hollowApp({ mode: 'codex', rows: 43 });
|
||||
app._maybePageCliTranscript({ deltaY: -100 }, -4);
|
||||
app._flushWheelSgrQueue();
|
||||
expect(sent).toEqual([]);
|
||||
expect(sent).toHaveLength(1);
|
||||
// Five more notches (20 rows, a page is 22) repay the page the first one took: no second page.
|
||||
for (let i = 0; i < 5; i++) app._maybePageCliTranscript({ deltaY: -100 }, -4);
|
||||
app._flushWheelSgrQueue();
|
||||
expect(sent).toHaveLength(1);
|
||||
|
||||
@@ -588,11 +588,11 @@ describe('page-key travel, cap and coalescing', () => {
|
||||
FakeFit.proposed = { cols: 80, rows: 36 };
|
||||
});
|
||||
|
||||
it('accumulates coarse sub-page travel before sending one page', async () => {
|
||||
it('pages a coarse opening event at once, and the next one repays it instead of paging again', async () => {
|
||||
const { ws, mount } = await connectTile(makeApp({ 's-tile': { mode: 'opencode' } }));
|
||||
|
||||
mount.fire('wheel', wheelLines(-10));
|
||||
expect(flushed(ws)).toEqual([]);
|
||||
expect(flushed(ws)).toEqual([{ t: 'i', d: PAGE_UP }]);
|
||||
mount.fire('wheel', wheelLines(-10));
|
||||
|
||||
expect(flushed(ws)).toEqual([{ t: 'i', d: PAGE_UP }]);
|
||||
@@ -946,14 +946,14 @@ describe('rows the tile pushed above the screen itself are not history', () => {
|
||||
}
|
||||
expect(flushed(ws)).toEqual([]);
|
||||
|
||||
// Back on the live screen, only travel made there counts: two quarter-screen
|
||||
// wheels are one PageUp, with nothing carried over from the wheels xterm had
|
||||
// (the gate sits before the pending travel is touched).
|
||||
// Back on the live screen, only travel made there counts: the first quarter-screen wheel pages at
|
||||
// once and the second repays it, with nothing carried over from the wheels xterm had (the gate sits
|
||||
// before the pending travel is touched).
|
||||
term.buffer.active.viewportY = baseY;
|
||||
const first = wheelLines(-6);
|
||||
mount.fire('wheel', first);
|
||||
expect(first.preventDefault).toHaveBeenCalled();
|
||||
expect(flushed(ws)).toEqual([]);
|
||||
expect(flushed(ws)).toEqual([{ t: 'i', d: PAGE_UP }]);
|
||||
mount.fire('wheel', wheelLines(-6));
|
||||
expect(flushed(ws)).toEqual([{ t: 'i', d: PAGE_UP }]);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user