🐛 fix(vscode): 代码阅读按 ⌘↓ 跳高亮不再来回闪,筛选栏加上上一处、下一处

This commit is contained in:
cruldra committed 2026-10-03 03:11:46 +08:00
1 parent 70a53e5a68
commit b16cc6409e
8 files changed
+221 -36

No files matched your search

@@ -1,3 +1,4 @@
import type { ScrollPosition } from './occurrences'
import type { DocumentMessage, Reveal } from './types'
import { useLayoutEffect } from 'react'
import { blockPath } from './filter'
@@ -24,12 +25,16 @@ export function flash(el: HTMLElement): void {
}
/** 把 el 滚进钉住的筛选栏下面的视口,规则见 scrollTopToShow:已经整个看得见就不滚。 */
export function showInViewport(el: HTMLElement): void {
/** 把 el 滚进钉住的筛选栏下面的视口,规则见 scrollTopToShow:已经整个看得见就不滚。beforeScroll 在真正滚动前拿到将要落到的位置。 */
export function showInViewport(el: HTMLElement, beforeScroll?: (position: ScrollPosition) => void): void {
const rect = el.getBoundingClientRect()
const pinned = pinnedHeight()
const top = scrollTopToShow({ top: rect.top + window.scrollY, bottom: rect.bottom + window.scrollY }, window.scrollY + pinned, window.innerHeight - pinned)
if (top !== undefined)
window.scrollTo(0, top - pinned)
if (top === undefined)
return
const position = { x: 0, y: top - pinned }
beforeScroll?.(position)
window.scrollTo(position.x, position.y)
}
/**