stevearc / oil.nvim

Neovim file explorer: edit your filesystem like a buffer
MIT License
3.84k stars 110 forks source link

bug: lpeg pattern fails to match #367

Closed stellarhoof closed 5 months ago

stellarhoof commented 5 months ago

Did you check the docs and existing issues?

Neovim version (nvim -v)

v0.10.0-dev-e948d7f

Operating system/version

MacOS Sonoma 14.4.1

Describe the bug

glob_pattern in this line fails to match a filename when renaming, causing lsp client to not notify the server of workspace/didRenameFiles.

The glob string is **/*.{ts,cts,mts,tsx,js,cjs,mjs,jsx} and the filename is 'packages/ui/src/rats/Button.tsx'

:lua =vim.glob.to_lpeg('**/*.{ts,cts,mts,tsx,js,cjs,mjs,jsx}'):match('packages/ui/src/rats/Button.tsx') also fails to match

If I remove glob_pattern in the linked code and instead use glob it works as intended.

Probably an issue with neovim itself?

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  1. nvim -u repro.lua
  2. Execute :lua =vim.glob.to_lpeg('**/*.{ts,cts,mts,tsx,js,cjs,mjs,jsx}'):match('packages/ui/src/rats/Button.tsx')

Expected Behavior

File renaming triggers workspace/didRenameFiles

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

Did you check the bug with a clean config?

stevearc commented 5 months ago

Yes, this is an issue upstream. There's not much I can do here, short of creating a new glob matching implementation. I'd recommend filing an issue upstream with the minimal vim.glob.to_lpeg repro. It would probably also be helpful if you can narrow down the repro a bit to determine which part of the pattern or path is causing problems.