From 257936b5803b5660428f29fdf4bae620f83b4018 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 16:55:58 -0300 Subject: diff -u in a command pane names its files though the terminal turned the tab before each timestamp into blanks A `---`/`+++` path was cut at the tab before diff -u's timestamp. Run in a command pane, the terminal had turned that tab into blanks, so the name took the timestamp with it and a look at a changed line opened nothing. The name is now also cut where blanks run up to a timestamp, either GNU diff's `2026-09-30 10:00:00...` or ctime's `Wed Sep 30 10:00:00 2026`. One blank is enough, since a tab can expand to a single blank, and the stamp is strict, so a name with blanks and no stamp after them stays whole. Tested on the parsed text and, in fs.py, on real `diff -u` output in a command pane, where a look at `+TWO` opens the new file. Co-Authored-By: Claude Opus 5.5 --- test/fs.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'test') diff --git a/test/fs.py b/test/fs.py index 80bee07f..9392ffb7 100644 --- a/test/fs.py +++ b/test/fs.py @@ -381,6 +381,25 @@ def discovery(binary, embedded=False): # Through a mount both read as EINVAL; the log says which and why. assert f'err {scratch} addr: no match for regexp\n'.encode() in client.read('/log') client.remove(f'/pane/{scratch}') + # Real `diff -u` in a command pane: the terminal turns the tab + # before each timestamp into blanks, and a look at a changed line + # still opens the new file at it. + (root / 'diff-old.txt').write_text('one\ntwo\nthree\n') + (root / 'diff-new.txt').write_text('one\nTWO\nthree\n') + seen = client.read('/log').decode().count('\nexit ') + client.write('/exec', b'diff -u diff-old.txt diff-new.txt\n') + deadline = time.monotonic() + 10 + while client.read('/log').decode().count('\nexit ') <= seen: + assert time.monotonic() < deadline, 'diff -u never ended' + time.sleep(.05) + ran = [row.split()[0] for row in client.read('/index').decode().splitlines() if row.split()[1] == 'term'] + shown = client.read(f'/pane/{ran[-1]}/body').decode() + assert '+++ diff-new.txt' in shown and '\t' not in shown, shown + client.write(f'/pane/{ran[-1]}/look', b'+TWO\n') + opened = [row for row in client.read('/index').decode().splitlines() if row.split()[3] == f'{root}/diff-new.txt'] + assert len(opened) == 1, client.read('/index') + client.remove(f'/pane/{opened[0].split()[0]}') + client.remove(f'/pane/{ran[-1]}') # A Save makes the directories its file goes in, whatever names # it: the pane's own name or Save's path. # `~` is home (this session's HOME, the test's root) wherever a -- cgit v1.3