⚡ perf(vscode): 代码阅读预览按卡片订阅状态:中文名、调用树棵数、单击高亮、问答一条消息只重画受影响的卡片和文字,新文档里内容没变的块沿用原来的对象不重画,没展开又没说过的块不画问答区
This commit is contained in:
1 parent
6e2c541558
commit
0ad4748cc6
27 files changed
+1359
-620
No files matched your search
@@ -46,6 +46,27 @@ describe('occurrences:哪些段画高亮', () => {
|
||||
expect(segmentOccurrence({ text: '\'./util\'', role: 'string', offset: 9 }, occurrences)).toBe('normal')
|
||||
})
|
||||
|
||||
it('出现很多、乱序、有长有短还互相重叠时,结果和逐处比一样', () => {
|
||||
const brute = (segment: Segment, occurrences: readonly Occurrence[]): string | undefined => {
|
||||
const hits = occurrences.filter(occurrence => occurrence.start < segment.offset! + segment.text.length && segment.offset! < occurrence.end)
|
||||
return hits.length === 0 ? undefined : hits.some(hit => hit.kind === 'write') ? 'strong' : 'normal'
|
||||
}
|
||||
let seed = 7
|
||||
const random = (n: number): number => {
|
||||
seed = (seed * 1103515245 + 12345) % 2147483648
|
||||
return seed % n
|
||||
}
|
||||
const kinds: Occurrence['kind'][] = ['read', 'write', 'text']
|
||||
const occurrences = Array.from({ length: 300 }, () => {
|
||||
const start = random(2000)
|
||||
return at(start, start + 1 + random(12), kinds[random(3)])
|
||||
})
|
||||
for (let offset = 0; offset < 2020; offset += 3) {
|
||||
const segment = name('x'.repeat(1 + (offset % 7)), offset)
|
||||
expect(segmentOccurrence(segment, occurrences), `offset ${offset}`).toBe(brute(segment, occurrences))
|
||||
}
|
||||
})
|
||||
|
||||
it('写入用强高亮色,读取和按文字认出的用普通高亮色;同一段碰上两种按写入画', () => {
|
||||
expect(occurrenceStyle('write')).toBe('strong')
|
||||
expect(occurrenceStyle('read')).toBe('normal')
|
||||
|
||||
Reference in new issue
Block a user