⚡ perf(vscode): 标差异时旧版本的解析结果按旧内容记着,晚到的答案、翻译插件没变就不再重新解析

This commit is contained in:
cruldra committed 2026-10-13 14:15:33 +11:00
1 parent e9c1c67d6f
commit 5a0c5490ea
8 files changed
+87 -8

No files matched your search

+9 -1
View File
@@ -24,6 +24,8 @@ export class DeferredAnswers<Q, A> {
/** 眼下这个版本查过(或正在查)的问题 */
private readonly checked = new Set<string>()
private timer: ReturnType<typeof setTimeout> | undefined
/** 查到的答案变过几次:按眼下的答案排出来的东西(对比用的旧版本)比这个数就知道还能不能接着用 */
private changes = 0
constructor(
private readonly idOf: (question: Q) => string,
@@ -34,6 +36,10 @@ export class DeferredAnswers<Q, A> {
private readonly schedule: (run: () => void, ms: number) => ReturnType<typeof setTimeout> = setTimeout,
) {}
get revision(): number {
return this.changes
}
session(): AnswerSession<Q, A> {
const asked = new Map<string, Q>()
return {
@@ -88,8 +94,10 @@ export class DeferredAnswers<Q, A> {
return
}
const id = this.idOf(question)
if (!this.same(this.known.get(id), found))
if (!this.same(this.known.get(id), found)) {
changed = true
this.changes++
}
this.known.set(id, found)
}))
return { unanswered, changed }