Skip to content

Commit d7f15cd

Browse files
committed
diff: an attempt to open gives way once the terminal loses room
The room only fed the decision to open: an attempt whose read found the terminal narrowed went on reading for each edit or command that landed during a read, with no room to open anything. It now ends there, and the next edit with room starts an attempt of its own. The README's `git status` sentence says where that read now happens: at the first fetch, the one an edit decides on included.
1 parent 3dbda69 commit d7f15cd

3 files changed

Lines changed: 43 additions & 3 deletions

File tree

‎mods/diff/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ forgets it); and the working tree is read only by a fetch for a pane that
5858
is open, after an edit that landed or a shell command that ran, or by the
5959
fetch each edit inside the repository, with room for a pane, makes until
6060
one lists a file and the pane opens on it. The one read the built-in has
61-
no counterpart for is a `git status` at a pane's first fetch, which stands
62-
in for the change time the built-in dates a moved file by.
61+
no counterpart for is a `git status` at the first of those fetches, which
62+
stands in for the change time the built-in dates a moved file by.
6363

6464
`hooks/register.ts` is the module; everything under `hooks/` is its parts.
6565

‎mods/diff/hooks/register.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,9 @@ export function register(on: On) {
514514
}
515515
}
516516

517-
if (seen === landed || isOvertaken) {
517+
const hasLostRoom = !isListing && !hasRoomFor(floor)
518+
519+
if (seen === landed || isOvertaken || hasLostRoom) {
518520
return
519521
}
520522

‎mods/diff/tests/register.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,44 @@ describe('register', () => {
875875
expect(world.opened, 'the room it read for is gone').toEqual([])
876876
})
877877

878+
test('nor does a command landing in that read have it read again, the next edit with room does', async ($, on) => {
879+
const world = Fixtures.inSlowRepository(on)
880+
881+
const edit = () =>
882+
$.tool.call({
883+
tool: 'Edit',
884+
file_path: '/work/app.ts',
885+
old_string: '1',
886+
new_string: '2',
887+
})
888+
889+
on('tool.call', () => ({ result: 'done' }))
890+
891+
await $.session.start(Fixtures.SESSION)
892+
await $.ui.render(Fixtures.HINT)
893+
await edit()
894+
await world.clock.settle()
895+
await $.ui.render(Fixtures.hintAt(Limits.AUTO_OPEN_MIN_COLUMNS - 1))
896+
await $.tool.call({ tool: 'Bash', command: 'make' })
897+
await world.clock.advance(Fixtures.SETTLE_MS)
898+
899+
expect(
900+
world.reads,
901+
'the attempt gave way with the room; it read for nothing more',
902+
).toEqual([0])
903+
904+
expect(world.opened).toEqual([])
905+
906+
await $.ui.render(Fixtures.HINT)
907+
await edit()
908+
await world.clock.advance(Fixtures.SETTLE_MS)
909+
910+
expect(
911+
world.opened.map(pane => pane.id),
912+
'wide again, the next edit starts an attempt of its own',
913+
).toEqual(['diff'])
914+
})
915+
878916
test("only the main loop's edit opens the pane", async ($, on) => {
879917
const world = Fixtures.inRepository(on)
880918

0 commit comments

Comments
 (0)