bug: error parsing oil buffers on filenames that differ by a space character
Did you check the docs and existing issues?
- [X] I have read the docs
- [X] I have searched the existing issues
Neovim version (nvim -v)
0.9.5
Operating system/version
Ubuntu 22.04
Describe the bug
When a directory contains a file named "x" and another file named " x" or "x " (added space before of after the name of the first file), oil.nvim fails with "Error parsing oil buffers". After saving the modified buffer, we can also see a diagnostic "Duplicate filename" next to one of the files, even though their names are not equal.
What is the severity of this bug?
tolerable (can work around it)
Steps To Reproduce
mkdir /tmp/test
touch "x"
touch " x"
nvim .
Then:
- add a line containing "y/" anywhere in the buffer
-
:w
Expected Behavior
Directory "y" should be created in /tmp/temp.
Directory structure
x/
x/
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
vim.cmd [[ :cd `mktemp -d` ]]
vim.cmd [[ :silent !mkdir "x" ]]
vim.cmd [[ :silent !mkdir " x" ]]
vim.cmd [[ :e . ]]
vim.cmd [[ :sleep 1 ]]
vim.cmd [[ :call append(line('.'), 'y/') ]]
vim.cmd [[ :w ]]
Did you check the bug with a clean config?
- [X] I have confirmed that the bug reproduces with
nvim -u repro.luausing the repro.lua file above.
This is a known issue. Oil does not handle files with leading whitespace very well. They will display properly, but the issue is that we use whitespace to separate the columns, so leading whitespace gets ignored when parsing the filename. There are maybe some things we could do to improve this, but it would take some effort.