⚡ perf(vscode): 代码阅读预览按卡片订阅状态:中文名、调用树棵数、单击高亮、问答一条消息只重画受影响的卡片和文字,新文档里内容没变的块沿用原来的对象不重画,没展开又没说过的块不画问答区
This commit is contained in:
1 parent
6e2c541558
commit
0ad4748cc6
27 files changed
+1359
-620
No files matched your search
@@ -1,9 +1,9 @@
|
||||
import type { ReactElement, RefObject } from 'react'
|
||||
import type { BlockView, StickyScrollSettings } from './types'
|
||||
import { useLayoutEffect, useMemo } from 'react'
|
||||
import { useContext, useLayoutEffect, useMemo } from 'react'
|
||||
import { KindIcon } from './kindIcons'
|
||||
import { SegmentText } from './SegmentText'
|
||||
import { HighlightContext } from './useOccurrences'
|
||||
import { SegmentText, TextMarksContext } from './SegmentText'
|
||||
import { selectStore } from './store'
|
||||
import { flash } from './useReveal'
|
||||
import { pinnedHeight, usePinnedHeight } from './useScrollPosition'
|
||||
import { STICKY_LINE_HEIGHT, stickyInset, useStickyLines } from './useStickyScroll'
|
||||
@@ -52,6 +52,9 @@ export function StickyLines({ content, blocks, settings }: { content: RefObject<
|
||||
const top = usePinnedHeight()
|
||||
const lines = useStickyLines(content, settings.maxLineCount)
|
||||
const byId = useMemo(() => blocksById(blocks), [blocks])
|
||||
// 钉着的名字照换中文名,不画页面上的高亮
|
||||
const marks = useContext(TextMarksContext)
|
||||
const unhighlighted = useMemo(() => selectStore(marks, ({ names }) => ({ names })), [marks])
|
||||
const count = lines.scopes.length
|
||||
const height = count * STICKY_LINE_HEIGHT + lines.offset
|
||||
|
||||
@@ -76,7 +79,7 @@ export function StickyLines({ content, blocks, settings }: { content: RefObject<
|
||||
}
|
||||
|
||||
return (
|
||||
<HighlightContext value={undefined}>
|
||||
<TextMarksContext value={unhighlighted}>
|
||||
<div className="cr-sticky" style={{ top, height }}>
|
||||
{lines.scopes.map((scope, index) => {
|
||||
const block = byId.get(scope.id)
|
||||
@@ -96,6 +99,6 @@ export function StickyLines({ content, blocks, settings }: { content: RefObject<
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</HighlightContext>
|
||||
</TextMarksContext>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user