mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-15 18:59:33 +01:00
fix: strip nested paste markers until none is left (release review, #726)
Ctrl+V's hand-built bracketed paste (#726) and the phone composer's dropped CSI 200~/201~ markers from the text in ONE pass, so a clipboard carrying ESC[20 ESC[201~ 1~ came out of it with an ESC[201~ that ended the frame early: everything after it was typed as keys and each CR ran. Both now strip until nothing matches. The composer's copy predates this release; it is the same one-liner. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ad9db7606
commit
9f7cba07ab
4 files changed
+29
-3
No files matched your search
@@ -255,8 +255,11 @@ Object.assign(CodemanApp.prototype, {
|
||||
// onData as user input (scroll to the bottom, clear the selection).
|
||||
// The main pane's bracketed-paste branch and a tile's _onTerminalData
|
||||
// deliver it, including the local-echo flush (#219). Do not also write
|
||||
// the frame from here.
|
||||
const body = text.replace(/\x1b\[20[01]~/g, '').replace(/\r?\n/g, '\r');
|
||||
// the frame from here. Markers are stripped until none is left: one pass over
|
||||
// `ESC[20` + `ESC[201~` + `1~` leaves an `ESC[201~` that would end the frame early.
|
||||
let body = text;
|
||||
while (/\x1b\[20[01]~/.test(body)) body = body.replace(/\x1b\[20[01]~/g, '');
|
||||
body = body.replace(/\r?\n/g, '\r');
|
||||
terminal.input(`\x1b[200~${body}\x1b[201~`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1246,7 +1246,11 @@ const KeyboardAccessoryBar = {
|
||||
// the single-line input transport and is what terminal.paste() emitted.
|
||||
// Paste markers inside the text are dropped first: a clipboard carrying
|
||||
// `ESC[201~` would end the bracket early and run the rest without Enter.
|
||||
const pasteText = text.replace(/\x1b\[20[01]~/g, '').replace(/\r?\n/g, '\r');
|
||||
// Strip until none is left: one pass over `ESC[20` + `ESC[201~` + `1~` leaves
|
||||
// an `ESC[201~` behind.
|
||||
let pasteText = text;
|
||||
while (/\x1b\[20[01]~/.test(pasteText)) pasteText = pasteText.replace(/\x1b\[20[01]~/g, '');
|
||||
pasteText = pasteText.replace(/\r?\n/g, '\r');
|
||||
if (pasteText.length > this._composerMaxLength) {
|
||||
app.showToast?.(`${label} is too long to send (maximum ${this._composerMaxLength.toLocaleString()} characters)`, 'error');
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user