mirror of
https://github.com/anomalyco/opencode.git
synced 2026-09-29 17:09:40 +08:00
fix(core): recover reads with quote and accent variants (#50953)
This commit is contained in:
@@ -135,9 +135,14 @@ export const Plugin = {
|
||||
.pipe(Effect.orDie)
|
||||
|
||||
const alternatePath = Effect.fn("ReadTool.alternatePath")(function* (absolute: string) {
|
||||
const base = basename(absolute).replace(/[\u00a0\u202f]/g, " ")
|
||||
const canonical = (name: string) =>
|
||||
name
|
||||
.normalize("NFC")
|
||||
.replace(/[\u00a0\u202f]/g, " ")
|
||||
.replace(/[\u2018\u2019]/g, "'")
|
||||
const base = canonical(basename(absolute))
|
||||
const matches = (yield* reader.list(AbsolutePath.make(dirname(absolute)))).filter(
|
||||
(entry) => entry.type === "file" && entry.name.replace(/[\u00a0\u202f]/g, " ") === base,
|
||||
(entry) => entry.type === "file" && canonical(entry.name) === base,
|
||||
)
|
||||
if (matches.length !== 1) return
|
||||
return join(dirname(absolute), matches[0].name)
|
||||
|
||||
Reference in New Issue
Block a user