🐛 fix(vscode): 代码阅读跳到参数、导入项、多变量声明里的一个时只闪属性表里那一行,按源码位置判断

This commit is contained in:
cruldra committed 2026-09-25 14:11:44 +08:00
1 parent 5b4ca903c5
commit 3ac1c783fb
14 files changed
+367 -47

No files matched your search

@@ -4,7 +4,7 @@ import { revealPlan, scrollTopToShow } from './reveal'
import { blockForLine } from './scrollPosition'
import { measureBlocks } from './useScrollPosition'
/** 让一块闪几下(codeReader.css 的 [data-flash]);正在闪的同一块再跳一次时从头闪。 */
/** 让一块或属性表里的一行闪几下(codeReader.css 的 [data-flash]);正在闪的同一处再跳一次时从头闪。 */
function flash(el: HTMLElement): void {
const running = el.getAnimations().filter(animation => animation instanceof CSSAnimation)
if (running.length > 0) {
@@ -25,7 +25,7 @@ function flash(el: HTMLElement): void {
/**
* 滚到 reveal 指的位置,处理完调 done:
* ① 从文本编辑器切过来(没有 definition):包含那一行的块顶到视口顶部,折叠着的不展开;
* ② 跳到定义:先展开把目标藏起来的块和属性行(expand 之后重新渲染,再进来一次),再把目标块滚进视口、闪几下。
* ② 跳到定义:先展开把目标藏起来的块和属性行(expand 之后重新渲染,再进来一次),再把目标(整块,或就是这处定义的属性行 / 子行)滚进视口、闪几下。
*/
export function useReveal(
doc: DocumentMessage | null,
@@ -50,7 +50,9 @@ export function useReveal(
expand(hidden)
return
}
const el = plan && document.querySelector<HTMLElement>(`.cr-block[data-id="${plan.id}"]`)
// 块正在编辑时页面上没有属性表,就闪整块
const row = plan?.row === undefined ? null : document.querySelector<HTMLElement>(`:is(.cr-prop-row, .cr-prop-item)[data-id="${plan.row}"]`)
const el = row ?? (plan && document.querySelector<HTMLElement>(`.cr-block[data-id="${plan.id}"]`))
if (el) {
const rect = el.getBoundingClientRect()
const top = scrollTopToShow({ top: rect.top + window.scrollY, bottom: rect.bottom + window.scrollY }, window.scrollY, window.innerHeight)