mirror of
https://github.com/anthropics/claude-code.git
synced 2026-10-02 05:25:05 +08:00
diff: the focus hook answers to either name the engine stamps on its elements
This commit is contained in:
@@ -3,7 +3,7 @@ export * from './command-name.js'
|
||||
export * from './keys'
|
||||
export * from './pane-id.js'
|
||||
export * from './pane-title.js'
|
||||
export * from './plugin-name.js'
|
||||
export * from './plugin-names.js'
|
||||
export * from './texts'
|
||||
|
||||
export * as default from '.'
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
/**
|
||||
* The plugin's own name, as the engine stamps it on the elements its render
|
||||
* hooks draw (`ui.press`, `ui.focus`).
|
||||
*/
|
||||
export const PLUGIN_NAME = 'diff'
|
||||
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* The names the engine may stamp on the elements this plugin's render hooks
|
||||
* draw (`ui.press`, `ui.focus`): its own, and the one a build that carries
|
||||
* it registers it under.
|
||||
*/
|
||||
export const PLUGIN_NAMES = ['diff', 'cc-plugin-diff'] as const
|
||||
@@ -833,7 +833,7 @@ export function register(on: On) {
|
||||
return result
|
||||
})
|
||||
|
||||
on('ui.focus', { plugin: Names.PLUGIN_NAME }, ($, e, next) => {
|
||||
on('ui.focus', { plugin: Names.PLUGIN_NAMES }, ($, e, next) => {
|
||||
const isListed =
|
||||
model.placement === 'inline' && model.dialogView === 'list' && host
|
||||
|
||||
|
||||
+3
-2
@@ -7,12 +7,13 @@ import { PANE } from './pane.js'
|
||||
* elements, as the engine raises it before the ring moves.
|
||||
*
|
||||
* @param key the element's key
|
||||
* @param plugin the name the engine stamped on the element
|
||||
* @returns the `ui.focus` input
|
||||
*/
|
||||
export const ringOnto = (key: string): UiFocusInput => ({
|
||||
export const ringOnto = (key: string, plugin = 'diff'): UiFocusInput => ({
|
||||
component: 'Pane',
|
||||
requestId: PANE.requestId,
|
||||
plugin: 'diff',
|
||||
plugin,
|
||||
element: key,
|
||||
origin: { kind: 'person' },
|
||||
})
|
||||
|
||||
@@ -200,6 +200,24 @@ describe('views', () => {
|
||||
expect(walked).not.toContain('file0.ts')
|
||||
})
|
||||
|
||||
test('the walk follows under the name a build registers', async ($, on) => {
|
||||
const world = Fixtures.inRepository(on, Fixtures.MANY_FILES)
|
||||
|
||||
await $.session.start(Fixtures.SESSION)
|
||||
await $.command.run(Fixtures.DIALOG_DIFF)
|
||||
await world.clock.advance(Fixtures.SETTLE_MS)
|
||||
await $.ui.render(Fixtures.INLINE_PANE)
|
||||
|
||||
expect(
|
||||
await $.ui.focus(Fixtures.ringOnto('file:file3.ts', 'cc-plugin-diff')),
|
||||
).toEqual({})
|
||||
|
||||
expect(
|
||||
world.focused.map(focus => focus.element),
|
||||
'its row once centred',
|
||||
).toEqual(['file:file2.ts'])
|
||||
})
|
||||
|
||||
test('off fullscreen, the walk stops at the last file', async ($, on) => {
|
||||
const world = Fixtures.inRepository(on, Fixtures.MANY_FILES)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user