mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-03 05:59:43 +02:00
Follow-up to #202. The dotdir decode landed there was reachable only when nothing else matched first, and in the greedy half it was not reachable at all. decodeProjectKey() splits the project key on '-', so the '/.' that the encoder collapses leaves an EMPTY segment behind. Both loops offered that empty string as a candidate directory name, and isDir(current + '/' + '') stats current + '/', which always succeeds. So the empty segment matched unconditionally: - backtracking half: ~/.sib resolved to "/home/x//sib" whenever a non-dot sibling ~/sib existed (wrong directory, and a doubled slash that then fails every string comparison against session.workingDir). Without a sibling it only backtracked out by luck. - greedy half: that loop is shortest-match-first, so the empty candidate matched on the FIRST iteration and set matched=true, leaving #202's dotdir branch permanently dead there. An empty string is never a real path component, so skip it in both loops. The unmatched tail then has to handle the empty segment too, or it would append a bare '/' and re-introduce the '//' path it just stopped producing; it now emits the dotdir guess instead, which is what the encoder implies. Regression test asserts both halves: the dotdir wins over the non-dot sibling, and the result never contains '//'. Verified it fails on #202 as merged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>