plenary.nvim icon indicating copy to clipboard operation
plenary.nvim copied to clipboard

Winpathfix

Open CheeseTurtle opened this issue 1 year ago • 1 comments

The misguided assumption that the path separator on Windows would always be a backslash, and therefore that checking if the path separator was a backslash was equivalent to checking if the OS was Windows, there were issues with path normalization when using forward slash as the path separator on Windows (with the 'shellslash' option set).

My tweaks involve checking for the existence of the 'shellslash' option to determine whether or not to use Windows-style paths, and (if it does exist) checking its value to determine which path separator to expect. I also added the invocation of the vim.fs.normalize function at the end of the Plenary path normalization function to hopefully catch any edge cases, although in hindsight it's probably best to only invoke it when there are still both forward and backward slashes in the path at that point.

CheeseTurtle avatar May 27 '24 05:05 CheeseTurtle

This is an interesting one. I'm tracking a ton of Windows path issues in Telescope and I was about to take a look into this issue.

Couple of thoughts from me:

  • I'm not sure what the state of unit tests for path_spec.lua is for Windows - have you run the tests with your changes? (ideally, we'd support both unix and windows testing in CI, I've done this for telescope so I can do the same for plenary)
  • I think using vim.fs.normalize is out, plenary doesn't declare a hard minimal neovim version but certainly for telescope, we support down to neovim 0.7 and I don't believe any of the vim.fs functions exists or if they do, vim.fs.normalize had some pretty significant changes recently.

jamestrew avatar Aug 13 '24 02:08 jamestrew