Skip to content

fix(path-spelling): name a misspelled symlink by the link, not its target - #1340

Merged
yumike merged 1 commit into
mainfrom
fix/spelling-hint-names-link
Oct 29, 2026
Merged

yumike merged 1 commit into
mainfrom
fix/spelling-hint-names-link

Conversation

@yumike

@yumike yumike commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up from the #1326 review. With docs/assets -> ../.github/assets, a page writing docs/Assets/badge.svg got the hint .github/assets/badge.svg, which names the link's target instead of the link. hint kept the written directories only up to the misspelled component and then took the canonical rest, which crosses the symlink.

Now hint walks the remaining components one at a time. Each one becomes the entry of its parent's listing that dir.join(written) opens:

  • an exact (NFC) member keeps its name
  • a plain entry takes the name canonicalize gives it (the premise the crate already relies on)
  • a link becomes the only link in that directory that canonicalizes to the same path, so LinkDir maps to linkdir and not to its target real in the same directory

Case is never folded. The scan runs only on the error path.

When two links in one directory lead to the same place, the target can't tell them apart. The hint then falls back to the canonical path rather than guess. The existing fallbacks don't change: a .. in the written prefix or the rest, and a component that does not resolve.

There are no new dependencies. Matching links by canonical path is enough here, so same-file isn't needed. It would not help anyway: it follows the final symlink.

Changed expectations:

  • LinkDir/a.md → linkdir/a.md (was real/a.md), Link.md → link.md (was real/a.md)
  • direct hint from linkdir for inlink/b.md → linkdir/inlink/b.md (was linkdir/foo/b.md): links past the misspelling keep their names too
  • rw-storage-fs read_file_spells_a_symlinked_folder_by_the_link: docs/assets/badge.svg (was .github/assets/badge.svg)

No CHANGELOG entry: the wrong-case hint hasn't been released yet.

Validation

  • TDD: I changed the expectations first and watched 3 tests fail on macOS (case-insensitive APFS). They pass after the fix.
  • New test a_misspelled_link_out_of_its_folder_keeps_the_links_name (case-insensitive FS only) covers the misspelled link, a misspelled name after the link, and the two-links fallback.
  • hints_keep_the_written_directories calls hint directly through two links, so it also runs on Linux.
  • make test, make lint, make format are clean.

🤖 Generated with Claude Code

@codspeed

codspeed Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 2 untouched benchmarks
⏩ 11 skipped benchmarks1


Comparing fix/spelling-hint-names-link (801eb86) with main (7b7c250)2

Open in CodSpeed

Footnotes

  1. 11 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (f55ae67) during the generation of this report, so 7b7c250 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

…rget

With docs/assets -> ../.github/assets, writing docs/Assets/badge.svg hinted .github/assets/badge.svg: the hint kept the written directories only up to the misspelling and took the canonical rest, which crossed the link. Each remaining component now takes its stored name: canonicalize's for a plain entry, and for a link the only link in its directory resolving to the same place, so the link sitting next to its target keeps its own name. Two links in one directory to the same place fall back to the canonical path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yumike
yumike force-pushed the fix/spelling-hint-names-link branch from 33827ef to 801eb86 Compare October 29, 2026 06:19
@yumike
yumike merged commit 92761b0 into main Oct 29, 2026
30 checks passed
@yumike
yumike deleted the fix/spelling-hint-names-link branch October 29, 2026 07:05
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.

1 participant