✨ feat(vscode): 代码阅读滚进卡片的子块时把外层卡片钉在顶上,同 VS Code 的 Sticky Scroll

This commit is contained in:
cruldra committed 2026-10-08 07:17:26 +08:00
1 parent 5ce2e904f4
commit eb3d1b90cd
17 files changed
+548 -31

No files matched your search

@@ -263,6 +263,8 @@ class Preview {
workspace.onDidChangeConfiguration((e) => {
if (this.ready && e.affectsConfiguration('editor.hover', document))
this.postHoverDelay()
if (this.ready && e.affectsConfiguration('editor.stickyScroll', document))
this.postStickyScroll()
}),
// 页面没 ready 时收不到,等它 ready 再随第一份文档之前补发
filter.subscribe((state) => {
@@ -539,6 +541,7 @@ class Preview {
// 先于文档发:第一份文档按筛选画,不会先整份露出来再藏
this.post({ type: 'filter', ...this.filter.current })
this.postHoverDelay()
this.postStickyScroll()
this.postQa()
void this.postProfiles()
await this.push()
@@ -662,6 +665,12 @@ class Preview {
this.post({ type: 'hoverDelay', delay: hover.get<number>('delay', 300), hidingDelay: hover.get<number>('hidingDelay', 300) })
}
/** VS Code 的 Sticky Scroll 设置(按这份文件取,语言自己的设置优先):页面按它把外层卡片钉在顶上。 */
private postStickyScroll(): void {
const sticky = workspace.getConfiguration('editor.stickyScroll', this.document)
this.post({ type: 'stickyScroll', enabled: sticky.get<boolean>('enabled', true), maxLineCount: sticky.get<number>('maxLineCount', 5) })
}
/**
* 回答 webview 第 id 次要定义卡片:offset 处名字的第一处定义所在那块(见 peekAt);指着的名字就是定义本身时没有。
* 下标属于别的文档版本时不答,webview 换了文档版本会收起浮窗