Skip to content

fix(windows): locate-current-file ignores active paths spelled differently from the tree - #1578

Draft
AACS111 wants to merge 5 commits into
1lck:previewfrom
AACS111:patch-2
Draft

AACS111 wants to merge 5 commits into
1lck:previewfrom
AACS111:patch-2

Conversation

@AACS111

@AACS111 AACS111 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

改动

  • 新增 toRootedPath(windows/tauri/src/utils/path-helpers.ts):把工作区根目录内的路径改写成根目录自己的前缀与分隔符写法,根目录之外的路径原样返回。
  • Project 标题栏“定位当前文件”按钮点击时,先用它转换活动路径,再请求展开祖先、选中并滚动(file-explorer-tree.tsx)。
  • 新增测试:file-explorer-reveal.test.tsx 覆盖“正斜杠活动路径 + 反斜杠根目录和节点”的真实定位链路,path-helpers.test.ts 覆盖 toRootedPath。
  • 更新 file-explorer.json 功能矩阵条目(evidence、verification、notes)。

原因

项目树节点沿用工作区根目录的写法(Windows 上为反斜杠),而编辑器的活动文件路径可能是正斜杠(例如经 Ctrl+P 快速打开得到的路径)。revealPathInTree 和 getAncestorDirectoryPaths 按字符串精确比较,祖先目录一个都匹配不上,于是既不展开也不滚动,也没有任何提示。

关联

Refs #1540。没有用 Closes:该 Issue 描述的是间歇性失效,本 PR 只修复其中已确认的“路径写法不一致”这一个原因,Issue 里猜测的其他原因没有验证。

验证

  • bun test src/utils src/features/file-explorer src/features/sidebar(windows/tauri):134 通过、0 失败。新增的定位测试在改动前失败(目录未被展开),改动后通过。
  • scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/preview HEAD 与 verify-platform-feature-matrix.sh 通过。
  • 在 Windows 开发构建(打开较大的 Maven 项目)里手动点击:从快速打开得到的文件可正确展开并定位。

未验证 / 未覆盖

  • 真实 WebView2 安装包实机、macOS 未验证(矩阵里仍为 pending);也没有等待 CI。
  • 活动行高亮等其他按路径精确比较的位置没有改动。
  • 运行 vp lint 对改动文件没有输出,我没有单独确认它是否实际执行了规则。

🤖 Generated with Claude Code

AACS111 and others added 5 commits October 29, 2026 18:09
Add toRootedPath, which respells a path inside the workspace root with the root's own prefix and separator, and use it when revealing the active file in the project tree.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Added tests for the toRootedPath function to ensure it correctly respells paths with the specified root prefix and separator.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…sh tree

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ghfind-review ghfind-review Bot added the review: low ghfind author score; see https://ghfind.com label Oct 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: low ghfind author score; see https://ghfind.com

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant