🐛 fix(vscode): 定义卡片里注释的 [Name] 渲染成链接,按卡片那份文件解析
This commit is contained in:
1 parent
af91b03857
commit
bea1f2e679
19 files changed
+319
-151
No files matched your search
@@ -11,7 +11,7 @@ import { DefinitionPeeks, linkPeekSource } from './definitionPeek'
|
||||
import { DiffText } from './DiffText'
|
||||
import { commentLinkOf } from './repoLink'
|
||||
import { hashed, NO_SPAN } from './testBlocks'
|
||||
import { MarkdownKindContext, TextPreview } from './TextPreview'
|
||||
import { TextPreview } from './TextPreview'
|
||||
|
||||
let container: HTMLDivElement
|
||||
let root: Root
|
||||
@@ -134,6 +134,7 @@ describe.each(['TextPreview', 'DiffText'] as const)('%s 的 Markdown 页面元
|
||||
expect(post).toHaveBeenLastCalledWith({ type: 'peekLink', id: 1, symbol: 'AsyncOpenAI' })
|
||||
const peek: DefinitionPeek = {
|
||||
path: 'client.py',
|
||||
uri: 'file:///w/client.py',
|
||||
line: 1,
|
||||
block: hashed([{ id: '1', anchor: '1', kind: 'class', span: NO_SPAN, attributes: { kind: 'class' }, concepts: [], children: [], translation: [] }])[0],
|
||||
names: [],
|
||||
@@ -147,22 +148,6 @@ describe.each(['TextPreview', 'DiffText'] as const)('%s 的 Markdown 页面元
|
||||
})
|
||||
})
|
||||
|
||||
it('组件 TextPreview 随注释与定义预览模式切换更新相同正文的链接', async () => {
|
||||
const preview = (kind: 'comment' | 'peek'): ReactElement => (
|
||||
<MarkdownKindContext value={kind}>
|
||||
<TextPreview text={{ markdown: '[Client]' }} />
|
||||
</MarkdownKindContext>
|
||||
)
|
||||
await render(preview('comment'))
|
||||
const original = anchor()
|
||||
await render(preview('peek'))
|
||||
expect(container.querySelector('a')).toBeNull()
|
||||
expect(container.textContent).toBe('[Client]\n')
|
||||
expect(original.isConnected).toBe(false)
|
||||
await render(preview('comment'))
|
||||
expect(anchor().getAttribute('href')).toBe('symbol:Client')
|
||||
})
|
||||
|
||||
it('组件 DiffText 更新正文时保留 Markdown 排版和增删标记', async () => {
|
||||
await render(<DiffText diff={{ markdown: [{ text: '[Client] ' }, { text: '旧说明', change: 'del' }, { text: '新说明', change: 'add' }] }} />)
|
||||
expect(anchor().textContent).toBe('Client')
|
||||
|
||||
Reference in new issue
Block a user