Skip to content

util+buffer: Accept both path separators on Windows - #4178

Open
4RH1T3CT0R7 wants to merge 1 commit into
micro-editor:masterfrom
4RH1T3CT0R7:fix/3828
Open

util+buffer: Accept both path separators on Windows#4178
4RH1T3CT0R7 wants to merge 1 commit into
micro-editor:masterfrom
4RH1T3CT0R7:fix/3828

Conversation

@4RH1T3CT0R7

@4RH1T3CT0R7 4RH1T3CT0R7 commented Aug 24, 2026

Copy link
Copy Markdown

On Windows both / and \ work as separators, but a couple of spots assume one. ReplaceHome() splits on / to find the end of the ~ component, so ~\foo.txt turns into a user lookup for the whole string and fails with "Could not find user". FileComplete() splits on os.PathSeparator only, so a forward-slash path like C:/Users/User/fo<Tab> gives no suggestions at all.

Both now normalize with filepath.ToSlash(), and completion hands back whichever separator the input already uses, so C:/Users/User/su completes to subdir/ rather than subdir\. No-ops on Unix, where \ is an ordinary filename character. Tests cover both separators.

#3955 rewrites the same ReplaceHome() line but hardcodes / more firmly, so ~\foo.txt still breaks there.

Fixes #3828

Windows accepts `/` as well as `\`, but `ReplaceHome()` only looked for
`/` when determining where the `~` component ends, while `FileComplete()`
only split on `os.PathSeparator` and always appended `os.PathSeparator`
to directory suggestions. As a result `~\foo.txt` was rejected with
"Could not find user", neither `~/foo`, `~\foo` nor `C:/Users/User/foo`
could be completed, and completing a directory mixed the separators.

Normalize the path with `filepath.ToSlash()` before splitting and keep
completing with the separator already in use. Both are a no-op on Unix,
where `\` is a regular filename character.

Fixes micro-editor#3828
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.

Tilde/Home paths are incompatible with filename completion on windows

1 participant