helix icon indicating copy to clipboard operation
helix copied to clipboard

fix: escape spaces in path completion

Open yo-main opened this issue 7 months ago • 1 comments

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 !

yo-main avatar Apr 21 '25 19:04 yo-main

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::expand so that it also works with gf.
  • this should only be done on linux

pascalkuthe avatar Jun 14 '25 12:06 pascalkuthe

I don't have much time atm to further dig this one out :disappointed:

yo-main avatar Jul 17 '25 19:07 yo-main