✨ feat(vscode): 代码阅读认出代码里起的中文名(Annotated[…, Comment("…")]、@Comment 装饰器、行尾 # @Comment、docstring / JSDoc 的参数说明),预览里定义和用到它的各处都写中文名,悬停看原名,定义处后面淡淡写原名

This commit is contained in:
cruldra committed 2026-09-27 00:56:39 +08:00
1 parent 1b1299dc1f
commit 44c221ea2b
45 files changed
+1685 -128

No files matched your search

@@ -42,7 +42,7 @@ export interface Click {
count: number
/** 点完页面上有选中的文字:这是拖着选字,不是点 */
selecting: boolean
/** 点中的带下标的名字 */
/** 点中的带下标的名字:源码下标,页面上显示的字(起了中文名的是中文名) */
name?: { offset: number, text: string }
/** 点在自己管点击的东西上:按钮、链接、输入框、下拉列表、筛选栏、属性名 */
control: boolean
@@ -175,8 +175,8 @@ export class OccurrenceHighlight {
private translatorId: string | undefined
/** 最近一次询问的 id;别的回答(点了别处、清掉之后才到的)都丢掉 */
private request = 0
/** 最近一次询问点中的那段名字;答过或清掉后没有 */
private asked: Segment | undefined
/** 最近一次询问点中的名字:源码下标和页面上显示的字;答过或清掉后没有 */
private asked: { offset: number, name: string } | undefined
/** 高亮着的名字没有当前那一处时,从这个源码下标(点中的名字)数起跳到哪一处 */
private from = 0
private current: Highlight | undefined
@@ -213,9 +213,9 @@ export class OccurrenceHighlight {
return
this.asked = undefined
const sorted = [...occurrences].sort((a, b) => a.start - b.start || a.end - b.end)
const current = sorted.findIndex(occurrence => overlaps(asked, occurrence))
this.from = asked.offset ?? 0
this.show(sorted.length > 0 ? { name: asked.text, occurrences: sorted, ...(current >= 0 && { current }) } : undefined)
const current = sorted.findIndex(occurrence => occurrence.start <= asked.offset && asked.offset < occurrence.end)
this.from = asked.offset
this.show(sorted.length > 0 ? { name: asked.name, occurrences: sorted, ...(current >= 0 && { current }) } : undefined)
}
/**
@@ -240,7 +240,7 @@ export class OccurrenceHighlight {
private find(offset: number, name: string): void {
if (this.version === undefined)
return
this.asked = { text: name, role: 'plain', offset }
this.asked = { offset, name }
this.post({ type: 'findOccurrences', id: ++this.request, version: this.version, offset })
}