Pasting (or drag-loading, or file-uploading) several MB of text into the <textarea> would lock up the browser for seconds while it laid out millions of characters. The bottleneck is the textarea itself, not the filter pipeline (filters only run on Save). Hold above-threshold (256 KB) content in a JS-side `bufferedContent` variable and render only the first 50 lines + a banner into the textarea. The Save path uses `bufferedContent` when set, so the upload sees the full content. The textarea becomes read-only while the buffer is active; user-typed input invalidates the buffer automatically (the textarea is the source of truth in normal mode). A new `loadContent(text)` helper is the single entry point: it chooses textarea vs. buffer based on length. All call sites (clipboard read, paste-event for text, file load, text drop) route through it. Threshold is 256 KB (above which textarea rendering visibly stutters); preview is 50 lines (enough to recognise the log without choking the renderer). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
13 KiB
13 KiB