fix(tmux): drop a leading blank line made of spaces, not only line breaks

`"  \nfix it\r"` still pasted a blank first line, because the leading strip
only matched `\n`. /^\s*\n/ drops everything up to the last leading line
break, mirroring the trimEnd() at the other end, and the first real line
keeps its indentation. The test row fails with the old pattern.

Co-Authored-By: Christian Haberl <116439789+christianhaberl@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
committed 2026-10-21 23:31:06 +02:00
1 parent 2fe9105bab
commit 9a00c2feaa
2 files changed
+13 -3

No files matched your search

+8 -3
View File
@@ -3863,9 +3863,14 @@ export class TmuxManager extends EventEmitter implements TerminalMultiplexer {
try {
const hasCarriageReturn = input.includes('\r');
// Leading and trailing line breaks are dropped, so `"\nfix it\r"` does not paste
// an empty first line (nor `"fix it\n\r"` an empty last one).
const textPart = input.replace(/\r/g, '').replace(/^\n+/, '').trimEnd();
// Leading and trailing blank lines are dropped, so neither `"\nfix it\r"` nor
// `" \nfix it\r"` pastes an empty first line (nor `"fix it\n\r"` an empty last
// one). The leading match ends at a line break, so the first real line keeps its
// indentation.
const textPart = input
.replace(/\r/g, '')
.replace(/^\s*\n/, '')
.trimEnd();
if (textPart && hasCarriageReturn) {
// Send text first, then Enter as a SEPARATE tmux command after a short delay.