✨ feat(vscode): 代码阅读滚进卡片的子块时把外层卡片钉在顶上,同 VS Code 的 Sticky Scroll
This commit is contained in:
1 parent
5ce2e904f4
commit
eb3d1b90cd
17 files changed
+548
-31
No files matched your search
@@ -97,12 +97,22 @@ export interface QaMessage {
|
||||
running: RunningAsk[]
|
||||
}
|
||||
|
||||
/**
|
||||
* VS Code 的 Sticky Scroll 设置(editor.stickyScroll.enabled / editor.stickyScroll.maxLineCount):预览滚进一张卡片的子块时把它钉在顶上,
|
||||
* 外层的在上、里层的在下,最多钉 maxLineCount 行。
|
||||
*/
|
||||
export interface StickyScrollSettings {
|
||||
enabled: boolean
|
||||
maxLineCount: number
|
||||
}
|
||||
|
||||
/**
|
||||
* reveal:已经开着的预览滚到某处(同 DocumentMessage.reveal)
|
||||
* definitionProbed:id 那次 probeDefinition 的回答,found 表示 VS Code 查得到定义
|
||||
* definitionPeeked:id 那次 peekDefinition / peekLink 的回答。查不到定义、定义所在的语言没有代码阅读、没有块盖住定义处、
|
||||
* 指着的名字就是定义本身时没有 peek,页面不弹浮窗
|
||||
* hoverDelay:VS Code 的 editor.hover.delay / editor.hover.hidingDelay(毫秒),鼠标停多久弹定义卡片、移开后多久收;ready 后发一次,设置改了再发
|
||||
* stickyScroll:VS Code 的 Sticky Scroll 设置(按这份文件取,语言自己的设置优先),见 StickyScrollSettings;ready 后发一次,设置改了再发
|
||||
* occurrencesFound:id 那次 findOccurrences 的回答,语言扩展没答(或没装)就是空的
|
||||
* filter:整个工作区共用的块筛选和「只看改动」开关;ready 后先于第一份文档发一次,之后任何一个预览改了都发给所有预览
|
||||
* qa:这份文件的问答;ready 后发一次,问答、正在答的问题变了再发
|
||||
@@ -126,6 +136,7 @@ export type ExtensionToWebview
|
||||
| { type: 'definitionProbed', id: number, found: boolean }
|
||||
| { type: 'definitionPeeked', id: number, peek?: DefinitionPeek }
|
||||
| { type: 'hoverDelay', delay: number, hidingDelay: number }
|
||||
| ({ type: 'stickyScroll' } & StickyScrollSettings)
|
||||
| { type: 'occurrencesFound', id: number, occurrences: Occurrence[] }
|
||||
| { type: 'moveOccurrence', step: 1 | -1 }
|
||||
| { type: 'displayNames', version: number, names: ShownName[] }
|
||||
|
||||
@@ -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 换了文档版本会收起浮窗
|
||||
|
||||
Reference in new issue
Block a user