diff --git a/mods/diff/README.md b/mods/diff/README.md index d8c2cf80..b62151ef 100644 --- a/mods/diff/README.md +++ b/mods/diff/README.md @@ -58,8 +58,8 @@ forgets it); and the working tree is read only by a fetch for a pane that is open, after an edit that landed or a shell command that ran, or by the fetch each edit inside the repository, with room for a pane, makes until one lists a file and the pane opens on it. The one read the built-in has -no counterpart for is a `git status` at a pane's first fetch, which stands -in for the change time the built-in dates a moved file by. +no counterpart for is a `git status` at the first of those fetches, which +stands in for the change time the built-in dates a moved file by. `hooks/register.ts` is the module; everything under `hooks/` is its parts. diff --git a/mods/diff/hooks/register.ts b/mods/diff/hooks/register.ts index 50fcdb6b..d7c53e58 100644 --- a/mods/diff/hooks/register.ts +++ b/mods/diff/hooks/register.ts @@ -514,7 +514,9 @@ export function register(on: On) { } } - if (seen === landed || isOvertaken) { + const hasLostRoom = !isListing && !hasRoomFor(floor) + + if (seen === landed || isOvertaken || hasLostRoom) { return } diff --git a/mods/diff/tests/register.test.ts b/mods/diff/tests/register.test.ts index ce02150d..4c332f3f 100644 --- a/mods/diff/tests/register.test.ts +++ b/mods/diff/tests/register.test.ts @@ -875,6 +875,44 @@ describe('register', () => { expect(world.opened, 'the room it read for is gone').toEqual([]) }) + test('nor does a command landing in that read have it read again, the next edit with room does', async ($, on) => { + const world = Fixtures.inSlowRepository(on) + + const edit = () => + $.tool.call({ + tool: 'Edit', + file_path: '/work/app.ts', + old_string: '1', + new_string: '2', + }) + + on('tool.call', () => ({ result: 'done' })) + + await $.session.start(Fixtures.SESSION) + await $.ui.render(Fixtures.HINT) + await edit() + await world.clock.settle() + await $.ui.render(Fixtures.hintAt(Limits.AUTO_OPEN_MIN_COLUMNS - 1)) + await $.tool.call({ tool: 'Bash', command: 'make' }) + await world.clock.advance(Fixtures.SETTLE_MS) + + expect( + world.reads, + 'the attempt gave way with the room; it read for nothing more', + ).toEqual([0]) + + expect(world.opened).toEqual([]) + + await $.ui.render(Fixtures.HINT) + await edit() + await world.clock.advance(Fixtures.SETTLE_MS) + + expect( + world.opened.map(pane => pane.id), + 'wide again, the next edit starts an attempt of its own', + ).toEqual(['diff']) + }) + test("only the main loop's edit opens the pane", async ($, on) => { const world = Fixtures.inRepository(on)