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

bug: symlink triggers lua error in oil/view.lua (replacement string contains newlines)

Open rasibn opened this issue 2 months ago • 0 comments

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)

v0.11.4 Release

Operating system/version

MacOS Version 15.7 and NixOS

oil version: commit 919e155


Steps to reproduce are

git clone https://github.com/hey-api/openapi-ts && cd openapi-ts
git checkout 7d086972b69d4d4a2e935e97a67608e4987194d6 # just incase

And then open this directory in oil

you get this error (blank page and an error message)

Image
   Error  03:32:36 msg_show.lua_error Error executing vim.schedule lua callback: ...e/rasib/.local/share/nvim/lazy/oil.nvim/lua/oil/view.lua:671: 'replacement string' item contains newlines
stack traceback:
	[C]: in function 'nvim_buf_set_lines'
	...e/rasib/.local/share/nvim/lazy/oil.nvim/lua/oil/view.lua:671: in function 'render_buffer'
	...e/rasib/.local/share/nvim/lazy/oil.nvim/lua/oil/view.lua:902: in function ''
	vim/_editor.lua: in function <vim/_editor.lua:0>

Deleting the README file fixes the issue

Image

What is the severity of this bug?

breaking (some functionality is broken)

Expected Behavior

Expected behavior is something like how other broken links are rendered

ln -s ghost test
Image

Sidenote

When I open this directory in snacks pickers it highlights the problematic README file as broken (red) so this might be an edge case missing from oil. Although on github and using cat / bat in the terminal I get the output file that's being pointed at so maybe this symlink is not broken 🤔

Image

Directory structure

Check github repo

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?

  • [x] I have confirmed that the bug reproduces with nvim -u repro.lua using the repro.lua file above.

rasibn avatar Oct 14 '25 23:10 rasibn