feat(directory-picker): filter subdirectories by typing a suffix - #461
Open
JingkaiTang wants to merge 3 commits into
Open
feat(directory-picker): filter subdirectories by typing a suffix#461JingkaiTang wants to merge 3 commits into
JingkaiTang wants to merge 3 commits into
Conversation
JingkaiTang
force-pushed
the
feat/directory-picker-filter
branch
from
August 12, 2026 03:49
83181a7 to
17df744
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.
背景
DirectoryPicker弹窗在「添加自定义路径 / 选择项目目录」时,当前目录下子目录较多需滚动查找,缺少快速定位手段。改动
复用现有路径输入框,输入
currentPath + "/" + 后缀时实时筛选当前目录的子目录:lib/directory-picker-filter.ts:deriveDirectoryFilter(currentPath, pathInput)推导筛选词、filterDirectoryEntries(entries, filter)过滤条目;配lib/directory-picker-filter.test.mjs单元测试。components/DirectoryPicker.tsx接入派生值filteredDirectories,列表数据源改用之;空状态区分「无匹配的子目录 / 没有子目录」。directoryPicker.noMatchingDirectories(中 / 英)。不新增输入框;不改
hasUncommittedPath/canSelect/navigateTo;不改后端/api/cwd/browse。交互
以
currentPath = /a/b为例:/a/b→ 显示全部子目录,「选择」可用。/a/b/foo→ 列表仅显示名字含foo(不区分大小写)的子目录,「选择」禁用;点击筛出的子目录进入下一层后,输入框同步为新路径,「选择」恢复可用。/c/d)→ 不筛选,跳转语义不变,点「转到目录」可跳转。筛选词取
currentPath后、首个分隔符之后的部分;两侧路径经normalizeFilePathSlashes归一,兼容 Windows\与/。测试
node --experimental-strip-types --test lib/directory-picker-filter.test.mjs:9/9 通过(含 Windows 斜杠归一、大小写不敏感包含、跳词语义返回 null)。tsc --noEmit:0 error。npm run lint:0 error。