codemaxxing 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +20 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1758,6 +1758,18 @@ let inBracketedPaste = false;
|
|
|
1758
1758
|
let burstBuffer = "";
|
|
1759
1759
|
let burstTimer = null;
|
|
1760
1760
|
const BURST_WINDOW_MS = 50; // Long enough for slow terminals to finish delivering paste
|
|
1761
|
+
// Debug paste: set CODEMAXXING_DEBUG_PASTE=1 to log all stdin chunks to /tmp/codemaxxing-paste-debug.log
|
|
1762
|
+
const PASTE_DEBUG = process.env.CODEMAXXING_DEBUG_PASTE === "1";
|
|
1763
|
+
import { appendFileSync } from "node:fs";
|
|
1764
|
+
function pasteLog(msg) {
|
|
1765
|
+
if (!PASTE_DEBUG)
|
|
1766
|
+
return;
|
|
1767
|
+
const escaped = msg.replace(/\x1b/g, "\\x1b").replace(/\r/g, "\\r").replace(/\n/g, "\\n");
|
|
1768
|
+
try {
|
|
1769
|
+
appendFileSync("/tmp/codemaxxing-paste-debug.log", `[${Date.now()}] ${escaped}\n`);
|
|
1770
|
+
}
|
|
1771
|
+
catch { }
|
|
1772
|
+
}
|
|
1761
1773
|
const origEmit = process.stdin.emit.bind(process.stdin);
|
|
1762
1774
|
function handlePasteContent(content) {
|
|
1763
1775
|
const normalized = content.replace(/\r\n/g, "\n").trim();
|
|
@@ -1786,7 +1798,9 @@ function flushBurst() {
|
|
|
1786
1798
|
return;
|
|
1787
1799
|
const buffered = burstBuffer;
|
|
1788
1800
|
burstBuffer = "";
|
|
1789
|
-
|
|
1801
|
+
const isMultiline = looksLikeMultilinePaste(buffered);
|
|
1802
|
+
pasteLog(`BURST FLUSH len=${buffered.length} multiline=${isMultiline}`);
|
|
1803
|
+
if (isMultiline) {
|
|
1790
1804
|
handlePasteContent(buffered);
|
|
1791
1805
|
}
|
|
1792
1806
|
else {
|
|
@@ -1801,12 +1815,14 @@ process.stdin.emit = function (event, ...args) {
|
|
|
1801
1815
|
}
|
|
1802
1816
|
const chunk = args[0];
|
|
1803
1817
|
let data = typeof chunk === "string" ? chunk : Buffer.isBuffer(chunk) ? chunk.toString("utf-8") : String(chunk);
|
|
1818
|
+
pasteLog(`CHUNK len=${data.length} raw=${data.substring(0, 200)}`);
|
|
1804
1819
|
// Aggressively strip ALL bracketed paste escape sequences from every chunk,
|
|
1805
1820
|
// regardless of context. Some terminals split markers across chunks or send
|
|
1806
1821
|
// them in unexpected positions. We never want \x1b[200~ or \x1b[201~ (or
|
|
1807
1822
|
// partial fragments like [200~ / [201~) to reach the input component.
|
|
1808
1823
|
const hadStart = data.includes("\x1b[200~") || data.includes("[200~");
|
|
1809
1824
|
const hadEnd = data.includes("\x1b[201~") || data.includes("[201~");
|
|
1825
|
+
pasteLog(`MARKERS start=${hadStart} end=${hadEnd} inBracketed=${inBracketedPaste}`);
|
|
1810
1826
|
// Strip full and partial bracketed paste markers
|
|
1811
1827
|
data = data.replace(/\x1b?\[20[01]~/g, "");
|
|
1812
1828
|
// ── Bracketed paste handling ──
|
|
@@ -1818,17 +1834,20 @@ process.stdin.emit = function (event, ...args) {
|
|
|
1818
1834
|
}
|
|
1819
1835
|
flushBurst();
|
|
1820
1836
|
inBracketedPaste = true;
|
|
1837
|
+
pasteLog("ENTERED bracketed paste mode");
|
|
1821
1838
|
}
|
|
1822
1839
|
if (hadEnd) {
|
|
1823
1840
|
bracketedBuffer += data;
|
|
1824
1841
|
inBracketedPaste = false;
|
|
1825
1842
|
const content = bracketedBuffer;
|
|
1826
1843
|
bracketedBuffer = "";
|
|
1844
|
+
pasteLog(`BRACKETED COMPLETE len=${content.length} lines=${content.split("\\n").length}`);
|
|
1827
1845
|
handlePasteContent(content);
|
|
1828
1846
|
return true;
|
|
1829
1847
|
}
|
|
1830
1848
|
if (inBracketedPaste) {
|
|
1831
1849
|
bracketedBuffer += data;
|
|
1850
|
+
pasteLog(`BRACKETED BUFFERING total=${bracketedBuffer.length}`);
|
|
1832
1851
|
return true;
|
|
1833
1852
|
}
|
|
1834
1853
|
// ── Burst buffering for non-bracketed paste ──
|