Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: inconsistent path separator conventions required on Windows #336

Closed
3 tasks done
djdv opened this issue Mar 22, 2024 · 1 comment
Closed
3 tasks done

bug: inconsistent path separator conventions required on Windows #336

djdv opened this issue Mar 22, 2024 · 1 comment
Labels
bug Something isn't working P0 Highest priority, will receive attention

Comments

@djdv
Copy link

djdv commented Mar 22, 2024

Did you check the docs and existing issues?

  • I have read the docs
  • I have searched the existing issues

Neovim version (nvim -v)

NVIM v0.10.0-dev-2682+g7d0a25fa8

Operating system/version

Windows 11 26085.1

Describe the bug

On Windows, Oil seems to require mixing path separator conventions.
I.e. requires the use of both / and \ simultaneously.

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

(Code blocks in this section will be the Oil buffer content.)
Screencast of this issue: https://www.youtube.com/watch?v=rziTssra0gw

When creating a directory, if the NT path delimiter \ is used

dir\

the 'create' action calls down to uv.fs_open which returns an ENOENT error.
Using the POSIX delimiter / works as expected.

dir/

However, you have to mix these conventions for sequences like 'create;move'
Consider starting with a directory like:

file.txt

to move 'file.txt' into 'dir' we have to do this:

dir/
dir\file.txt

which applies without error.

Trying to do

dir/
dir/file.txt

results in a parsing error from Oil: Filename cannot contain '/'.

Expected Behavior

I expect Oil to enforce 1 of either conventions, preferably the platform native convention.

Directory structure

No response

Repro

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
        "stevearc/oil.nvim",
        config = function()
            require("oil").setup({
              -- add any needed settings here
            })
        end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Did you check the bug with a clean config?

  • I have confirmed that the bug reproduces with nvim -u repro.lua using the repro.lua file above.
@stevearc
Copy link
Owner

I've made some changes to treat / and \ the same on windows. In general we prefer to use the posix style in oil, but using a backslash should still work and not produce any unexpected behavior.

You may be less pleased about one of the changes though. It so happens that being able to move a file into a directory by renaming it from file.txt -> dir\file.txt is actually a bug and is intentionally not a feature. The fact that it worked in windows was actually a mistake, and has been fixed. Check out #117 if you want more details on why this is not a feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0 Highest priority, will receive attention
Projects
None yet
Development

No branches or pull requests

2 participants