feat(file-icons): 文件树/文件 tab 图标多样化 + registerFileIcon API(目录保留扩展名 + 全局默认兜底) - #531
Open
Menghuan1918 wants to merge 2 commits into
Open
feat(file-icons): 文件树/文件 tab 图标多样化 + registerFileIcon API(目录保留扩展名 + 全局默认兜底)#531Menghuan1918 wants to merge 2 commits into
Menghuan1918 wants to merge 2 commits into
Conversation
- 新增内置扩展名→glyph 映射(md/媒体/pdf/json/代码/配置/数据库/压缩包, 单色 currentColor 遵循皮肤契约,未知扩展回退 VscFile) - ctx.betterSidebar 新增 registerFileIcon/getFileIcons/matchFileIcon (priority 降序,同优先级 catch-all 垫底),features 增加 'fileIcons' - FileTree 文件行消费注册表:注册图标优先(可为彩色 ReactNode, 工厂抛错回退内置),注册/注销即时生效 - 同步 docs/external-plugin-guide.md §7 与 tests/file-icons.spec.ts
- registerFileIcon 保留 'folder'/'folder-open' 特殊扩展名:目录行(含根行) 图标可注册,匹配保留值不认领真实 .folder 文件 - 新增权威解析器 fileIcon(path,size)(具体注册 → 内置 glyph → catch-all 全局默认 → VscFile,逐工厂崩溃隔离)与 folderIcon(path,open,size); matchFileIcon 收窄为仅具体扩展名匹配 - 编辑器文件 tab(非 meta.dir)与文件树行显示同一 fileIcon 图标 - 同步 external-plugin-guide §7(保留值/回退链/三例注册)与 README (功能一览、v0.19.0-alpha.0 发布注记、服务化扩展章节) - tests/file-icons.spec.tsx 重写为 17 用例(链序/保留值/目录/崩溃回退)
Menghuan1918
force-pushed
the
feat/file-icons-api
branch
from
September 3, 2026 11:58
adbcb0d to
0d32bfd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更内容
优化文件图标显示:文件树与编辑器文件 tab 不再是单一
VscFile单色图标,并提供对外图标注册 API。内置多 glyph(KISS,遵循皮肤契约)
src/client/file-icons.tsx:扩展名 → VSCodicons glyph 映射(markdown / 媒体 / pdf / json / 40+ 代码扩展 / 配置 / 数据库 / lock / 压缩包),全部currentColor单色;未知扩展回退VscFile。对外 API(feature
fileIcons)ctx.betterSidebar.registerFileIcon(descriptor)/getFileIcons()/matchFileIcon(path)/matchFolderIcon(open)/fileIcon(path, size)/folderIcon(path, open, size):'folder'(闭合)/'folder-open'(展开)经同一exts机制注册目录行图标;保留值不认领真实.folder文件。exts: []的注册只兜内置 glyph 没认领的扩展名——链条为「具体扩展名注册 → 内置 glyph → catch-all 全局默认 → VscFile」,注册的通用默认不吞掉内置多样性。fileIcon/folderIcon内置完整回退链 + 逐工厂崩溃隔离(抛错 console.error 后跳下一级),消费方零防御代码。消费表面
type==='editor' && path && !meta.dir,与树对应);文件夹窗口 / explorer / browser tab 不变。搜索结果行扩展已按 review 意见收敛放弃。文档
docs/external-plugin-guide.md§7:保留值语义、回退链、三例注册(具体扩展名 / 目录 / 全局默认)。README.md:功能一览「文件工作台」、v0.19.0-alpha.0 发布注记、服务化扩展章节。验证
pnpm typecheck✅pnpm test:新增tests/file-icons.spec.tsx17 用例全绿(链序、保留值、目录注册、崩溃回退);失败集与 main 基线完全一致(26 个预存环境失败,stash 对照验证)pnpm build✅(无新依赖,react-icons/vsc 核心包已有先例)