surshar / claude-code
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
Built by Anthropic · github.com/anthropics
| Mmods/diff/hooks/drawn-files-of/drawn-files-of.ts |
| Mmods/diff/hooks/register.ts |
| Mmods/diff/tests/fixtures/index.ts |
| Amods/diff/tests/fixtures/with-lockfile.ts |
| Mmods/diff/tests/views.test.ts |
| @@ -18,11 +18,16 @@ | ||
| 18 | 18 | model: PaneState.PaneModel, |
| 19 | 19 | ): readonly Git.FileStat[] { |
| 20 | 20 | const files = model.data?.files ?? [] |
| 21 | - const listed = Views.dialogEntriesOf(model).map(entry => entry.path) | |
| 22 | - const start = Views.dialogWindowOf(model, listed) | |
| 23 | - const windowed = listed.slice(start, start + Limits.MAX_VISIBLE_FILES) | |
| 24 | - const isTurn = PaneState.pickedTurnOf(model) !== undefined | |
| 25 | 21 | |
| 22 | + if (model.placement === 'inline') { | |
| 23 | + const isTurn = PaneState.pickedTurnOf(model) !== undefined | |
| 24 | + const listed = Views.dialogEntriesOf(model).map(entry => entry.path) | |
| 25 | + const start = Views.dialogWindowOf(model, listed) | |
| 26 | + const windowed = listed.slice(start, start + Limits.MAX_VISIBLE_FILES) | |
| 27 | + | |
| 28 | + return files.filter(file => !isTurn && windowed.includes(file.path)) | |
| 29 | + } | |
| 30 | + | |
| 26 | 31 | const partition = PaneState.partitionOf( |
| 27 | 32 | files, |
| 28 | 33 | model.isNoiseShown ? 'shown' : 'hidden', |
| @@ -32,8 +37,5 @@ | ||
| 32 | 37 | model.isPreSessionShown && |
| 33 | 38 | partition.preSession.length <= Limits.PRE_SESSION_BODY_CAP |
| 34 | 39 | |
| 35 | - const docked = [...partition.shown, ...(isBodied ? partition.preSession : [])] | |
| 36 | - const inDialog = files.filter(file => !isTurn && windowed.includes(file.path)) | |
| 37 | - | |
| 38 | - return model.placement === 'inline' ? inDialog : docked | |
| 40 | + return [...partition.shown, ...(isBodied ? partition.preSession : [])] | |
| 39 | 41 | } |
| @@ -728,6 +728,11 @@ | ||
| 728 | 728 | |
| 729 | 729 | columns = e.viewport?.columns ?? columns |
| 730 | 730 | |
| 731 | + /** | |
| 732 | + * A seat that changed since the last drawing lists other rows, whose | |
| 733 | + * bodies are read once: the model takes the new seat in this same pass, | |
| 734 | + * so the drawing that read asks for finds the seat unchanged. | |
| 735 | + */ | |
| 731 | 736 | const isReseated = e.props.placement !== model.placement |
| 732 | 737 | |
| 733 | 738 | model = { |
| @@ -61,6 +61,7 @@ | ||
| 61 | 61 | export * from './vs-main.js' |
| 62 | 62 | export * from './wheel-over-list.js' |
| 63 | 63 | export * from './wheel-tick.js' |
| 64 | +export * from './with-lockfile.js' | |
| 64 | 65 | export * from './worktree' |
| 65 | 66 | export * from './wrapped-lines' |
| 66 | 67 |
| @@ -1,0 +1,10 @@ | ||
| 1 | +import { answersOf } from './answers-of.js' | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * Git's output in /work where a source file and a lockfile changed, the | |
| 5 | + * lockfile a generated file the docked pane hides until asked. | |
| 6 | + */ | |
| 7 | +export const WITH_LOCKFILE = answersOf('1\t1\tapp.ts\0' + '1\t1\tbun.lock\0', { | |
| 8 | + 'app.ts': '@@ -1 +1 @@\n-const a = 1\n+const a = 2\n', | |
| 9 | + 'bun.lock': '@@ -1 +1 @@\n-"left": "1.0.0"\n+"left": "1.0.1"\n', | |
| 10 | +}) |
| @@ -124,6 +124,29 @@ | ||
| 124 | 124 | expect(drawn).not.toContain('+d') |
| 125 | 125 | }) |
| 126 | 126 | |
| 127 | + test('inline, a file the docked pane hides opens too', async ($, on) => { | |
| 128 | + const world = Fixtures.inRepository(on, Fixtures.WITH_LOCKFILE) | |
| 129 | + | |
| 130 | + await $.session.start(Fixtures.SESSION) | |
| 131 | + await $.command.run(Fixtures.DIALOG_DIFF) | |
| 132 | + await world.clock.advance(Fixtures.SETTLE_MS) | |
| 133 | + await $.ui.render(Fixtures.INLINE_PANE) | |
| 134 | + | |
| 135 | + expect(await $.ui.press({ plugin: 'diff', key: 'file:bun.lock' })).toEqual({ | |
| 136 | + element: 'file:bun.lock', | |
| 137 | + }) | |
| 138 | + | |
| 139 | + await world.clock.advance(Fixtures.SETTLE_MS) | |
| 140 | + | |
| 141 | + const drawn = Fixtures.textOf(await $.ui.render(Fixtures.INLINE_PANE)) | |
| 142 | + | |
| 143 | + expect(drawn, 'generated, and still a listed row').not.toContain( | |
| 144 | + 'Loading diff', | |
| 145 | + ) | |
| 146 | + | |
| 147 | + expect(drawn).toContain('+"left": "1.0.1"') | |
| 148 | + }) | |
| 149 | + | |
| 127 | 150 | test('docked, a wheel tick moves the body, not the list', async ($, on) => { |
| 128 | 151 | const world = Fixtures.inRepository(on, Fixtures.MANY_FILES) |
| 129 | 152 |