helix
helix copied to clipboard
fix: escape spaces in path completion
close https://github.com/helix-editor/helix/issues/13371
The flows for completion approximately goes like path_completion -> compile_path_regex -> path_component
The path_component regex expects spaces to be escaped, however the path_completion function provides unescaped spaces.
The PR tries to fix the original issue by correctly escaping spaces in path (and attempt to do it only in path). I'm not sure if that is the best way to go, happy to collect feedback on this !
this is not nearly as trivial as it may seem
- if a path is quoted then backslash escapes are not valid, detecting quotes will be language dependent (if the quote starts just before the path that would be trivial but the quote can contain more and which escapes are valid depends on the language).
- on windows they are not supported at all (backslashes are part seperators there)
probably we still want to support this on linux because it's quite unlikely somebody will actually create file named foo\ bar (with the backslash as actual part of the filename). But I don't love that we loose the ability to properly handle that case.
implementation wise:
- this should be handled as part of
path::expandso that it also works withgf. - this should only be done on linux
I don't have much time atm to further dig this one out :disappointed: