✨ feat(vscode): 代码阅读预览加 ⌘F 查找栏:整份文件查(折叠着的块里的也算,跳过去时展开),按页面上显示的字不分大小写匹配、中文名也认原名,Enter / ⌘G 跳、Esc 关,高亮直接画在页面上不重画卡片
This commit is contained in:
1 parent
cc3fcda051
commit
bd474986bd
27 files changed
+1833
-114
No files matched your search
@@ -9,6 +9,7 @@ import { describe, expect, it, vi } from 'vitest'
|
||||
import { commands, window, workspace } from 'vscode'
|
||||
import { documentMessage } from './documentMessage'
|
||||
import { documentSymbolNodes } from './documentSymbols'
|
||||
import { FIND_CONTEXT } from './findCommands'
|
||||
import { OCCURRENCES_CONTEXT } from './occurrenceNavigation'
|
||||
import { PREVIEW_VIEW_TYPE, PreviewEditorProvider } from './previewEditor'
|
||||
|
||||
@@ -563,3 +564,46 @@ describe('注释里不带路径的引用按它写在哪块的注释里找', () =
|
||||
expect(page.posted()).toContainEqual({ type: 'repoLinkBroken', symbol: 'get_agent_admitted', block: HELPER })
|
||||
})
|
||||
})
|
||||
|
||||
describe('预览里的查找栏', () => {
|
||||
const sent = (page: ReturnType<typeof tab>): ExtensionToWebview[] => page.posted().filter(msg => msg.type === 'openFind' || msg.type === 'moveFind')
|
||||
|
||||
it('「查找」发给活动的预览;「查找下一处 / 上一处」发给查找栏开着、有焦点的那个,都没有时发给活动的;还没 ready 的不发', async () => {
|
||||
const { provider, document } = opening()
|
||||
const first = tab()
|
||||
const second = tab()
|
||||
await provider.open(document.uri as never, {}, async () => provider.resolveCustomTextEditor(document as never, first.panel))
|
||||
await provider.open(document.uri as never, {}, async () => provider.resolveCustomTextEditor(document as never, second.panel))
|
||||
provider.find()
|
||||
expect([...sent(first), ...sent(second)]).toEqual([])
|
||||
|
||||
await first.send({ type: 'ready' })
|
||||
await second.send({ type: 'ready' })
|
||||
first.hide()
|
||||
provider.find()
|
||||
expect(sent(first)).toEqual([])
|
||||
expect(sent(second)).toEqual([{ type: 'openFind' }])
|
||||
|
||||
second.clear()
|
||||
await first.send({ type: 'findNavigation', available: true })
|
||||
provider.moveFind(1)
|
||||
expect(sent(first)).toEqual([{ type: 'moveFind', step: 1 }])
|
||||
expect(sent(second)).toEqual([])
|
||||
|
||||
await first.send({ type: 'findNavigation', available: false })
|
||||
provider.moveFind(-1)
|
||||
expect(sent(second)).toEqual([{ type: 'moveFind', step: -1 }])
|
||||
})
|
||||
|
||||
it('页面报来查找栏开着、有焦点:设上下文键,⌘G 这时才归查找栏;变了才设', async () => {
|
||||
const { provider, document } = opening()
|
||||
const page = tab()
|
||||
await provider.open(document.uri as never, {}, async () => provider.resolveCustomTextEditor(document as never, page.panel))
|
||||
vi.mocked(commands.executeCommand).mockClear()
|
||||
await page.send({ type: 'findNavigation', available: true })
|
||||
await page.send({ type: 'findNavigation', available: true })
|
||||
await page.send({ type: 'findNavigation', available: false })
|
||||
expect(vi.mocked(commands.executeCommand).mock.calls.filter(([command, key]) => command === 'setContext' && key === FIND_CONTEXT))
|
||||
.toEqual([['setContext', FIND_CONTEXT, true], ['setContext', FIND_CONTEXT, false]])
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user