Skip to content

fix: prevent nested folders from receiving special icons.#561

Merged
MakinoharaShoko merged 1 commit intoOpenWebGAL:devfrom
fltLi:fix/folder-icon
Apr 7, 2026
Merged

fix: prevent nested folders from receiving special icons.#561
MakinoharaShoko merged 1 commit intoOpenWebGAL:devfrom
fltLi:fix/folder-icon

Conversation

@fltLi
Copy link
Copy Markdown
Contributor

@fltLi fltLi commented Feb 20, 2026

fix: #525

为嵌套在特殊目录下, 拥有特殊名称的文件夹 (例如 scene/figure) 赋予特殊图标是无意义的.
这么做容易引起混淆, 而且其下的资源也无法使用

Only folders directly under the root should get special folder icons (e.g., folder-images, folder-audio). Previously, a path like "scene/figure/video/" would also match the mapping because its base name "video" is in the mapping list, leading to incorrect icons.

This change adds `hasSpecialParent` to check whether any ancestor directory is a known special folder. If so, the folder is treated as unknown and falls back to the default folder icon.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @fltLi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此拉取请求旨在解决一个问题,即嵌套在特殊目录下的文件夹(例如 scene/figure)被错误地赋予了特殊图标。这种行为可能导致用户混淆,并影响其下资源的可用性。通过引入一个检查特殊祖先目录的机制,此更改确保只有顶层或非嵌套的特殊目录才能获得其对应的特殊图标,从而提高了文件图标显示的准确性和用户体验。

Highlights

  • 新增辅助函数: 新增了 hasSpecialAncestor 辅助函数,用于检查文件路径中是否存在特殊祖先目录。
  • 优化文件类型判断逻辑: 修改了 getFileType 函数,在判断文件类型时,如果文件或文件夹嵌套在特殊目录下,则不再赋予其特殊图标,而是返回 'unknown' 类型,以避免混淆。
Changelog
  • packages/origine2/src/utils/getFileIcon.ts
    • 新增了 hasSpecialAncestor 函数,用于检测给定路径中是否存在特殊祖先目录。
    • 修改了 getFileType 函数,在确定文件类型之前,会先调用 hasSpecialAncestor 函数,如果存在特殊祖先目录,则直接返回 'unknown' 类型。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

这个 PR 旨在防止嵌套的特殊文件夹获取特殊图标。实现上引入了一个辅助函数 hasSpecialAncestor 并在 getFileType 中使用它。这个逻辑是正确的,但目前的实现存在一个关于路径处理的 bug,当路径以斜杠结尾时会导致不正确的行为。我提供了一个建议来修复这个问题。

Comment thread packages/origine2/src/utils/getFileIcon.ts
@fltLi fltLi changed the base branch from main to dev April 5, 2026 05:36
@MakinoharaShoko MakinoharaShoko merged commit f088ad1 into OpenWebGAL:dev Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

浏览资源时, 名称为 figure 等内置路径的目录图标错误.

2 participants