✨ feat(vscode): 预览里代码的上色和卡片种类色跟着当前颜色主题走
This commit is contained in:
1 parent
19302bbed0
commit
dff38ee0c5
26 files changed
+1286
-75
No files matched your search
@@ -12,6 +12,7 @@ import type { CodeReaderRegistry } from '../registry'
|
||||
import type { LookupSources } from '../ruleLookups'
|
||||
import type { TreeSitterRuntime } from '../runtime'
|
||||
import type { ImportedName, LinkTarget, SymbolNode } from '../symbolLinks'
|
||||
import type { ThemeColors } from '../theme/codeColors'
|
||||
import type { BlockFilter } from './blockFilter'
|
||||
import type { FoundLocation } from './definitions'
|
||||
import type { ChatKind, DefinitionPeek, ExtensionToWebview, Occurrence, Reveal, SymbolReference, WebviewToExtension } from './messages'
|
||||
@@ -82,6 +83,8 @@ export class PreviewEditorProvider implements CustomTextEditorProvider {
|
||||
private readonly registry: CodeReaderRegistry,
|
||||
private readonly runtime: TreeSitterRuntime,
|
||||
private readonly filter: BlockFilter,
|
||||
/** 代码配色:各预览共用当前颜色主题的那一份,换了主题、改了代码配色的设置时发给订阅的 */
|
||||
readonly codeColors: Pick<ThemeColors, 'current' | 'subscribe'>,
|
||||
/** 库规则标的引用去哪儿查定义(交给标它的规则) */
|
||||
readonly resolveReference: (reference: RuleReference) => Promise<RuleLocation[]>,
|
||||
/** 问 AI:各预览共用,同一份文件开在几处时问答、正在答的问题都一样 */
|
||||
@@ -284,6 +287,11 @@ class Preview {
|
||||
if (this.ready)
|
||||
this.post({ type: 'filter', ...state })
|
||||
}),
|
||||
// 同上:没 ready 的等 ready 时在第一份文档之前发眼下的
|
||||
owner.codeColors.subscribe((colors) => {
|
||||
if (this.ready)
|
||||
this.post({ type: 'codeColors', ...colors })
|
||||
}),
|
||||
// 项目的入口变了:重新发文档,卡片左边的入口图标跟着变
|
||||
owner.entries.onDidChange((uris) => {
|
||||
if (uris.some(uri => uri.toString() === document.uri.toString()))
|
||||
@@ -605,6 +613,8 @@ class Preview {
|
||||
this.postQa()
|
||||
for (const kind of CHAT_KINDS)
|
||||
void this.postProfiles(kind)
|
||||
// 也先于文档发:第一份文档一画出来就是主题的颜色,不会先没颜色再闪一下
|
||||
this.post({ type: 'codeColors', ...await this.owner.codeColors.current() })
|
||||
await this.push()
|
||||
if (this.pendingPathFocus)
|
||||
this.focusPathAsk()
|
||||
|
||||
Reference in new issue
Block a user