fix(tmux): drop leading line breaks from sendInput text

"\nfix it\r" pasted an empty first line. Leading line breaks are now
dropped like trailing ones. Document what useMux does with a line feed,
and that a pane without bracketed paste receives each pasted line break
as CR, so a multi-line write without \r runs every line but the last
there, where the old line-stripping typed the joined text and ran nothing.

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 08:03:54 +02:00
1 parent 3b747774f1
commit cf9511cb57
4 files changed
+27 -3

No files matched your search

+15
View File
@@ -252,6 +252,21 @@ describe('sendInput line breaks', () => {
expect(bufferText(manager.ran[0])).toBe('one\ntwo');
});
it('drops leading line breaks instead of pasting an empty first line', async () => {
const single = managerWithSession();
await single.sendInput('s1', '\nfix it\r');
expect(bufferText(single.ran[0])).toBe('fix it');
const multi = managerWithSession();
await multi.sendInput('s1', '\r\n\r\none\ntwo\r');
expect(bufferText(multi.ran[0])).toBe('one\ntwo');
// Without an Enter, what is left is one line, so it is typed like any other.
const typed = managerWithSession();
await typed.sendInput('s1', '\n\njust type');
expect(typed.ran).toEqual([expect.stringMatching(/ send-keys -t "codeman-abc12345" -l 'just type'$/)]);
});
it('leaves single-line input as it was: pasted with Enter, typed without', async () => {
const submitted = managerWithSession();
await submitted.sendInput('s1', 'read your inbox\r');