withoutTerminalReports(chunk: Buffer): Buffer
The same bytes with the terminal's answers to ITSELF dropped: mouse and cursor-position reports.
These are input in the sense that they arrive on stdin, and never in the sense that anyone typed
them. An editor turns mouse tracking on; the terminal then reports every click and drag as
ESC [ < 32 ; 14 ; 45 M, and the ones that arrive while nobody is reading sit in the TTY buffer
until somebody is. That somebody was the prompt, which rendered them as text and then failed to
parse them — the 32;14;45M32;11;45M… after quitting nvim, and the Invalid or unexpected token on the line after.
Filtered by SHAPE rather than by timing: a report is recognisable, and dropping it is right whenever it turns up. A settle window would only be a guess about how long the mess lasts.
import { withoutTerminalReports } from './index.ts'; const ESC = String.fromCharCode(27); withoutTerminalReports(Buffer.from(`a${ESC}[<32;14;45Mb`)).toString(); // 'ab' withoutTerminalReports(Buffer.from('1 + 1')).toString(); // '1 + 1' — typing is untouched