fix: string.find() matching for only_cwd option (builtin.buffers) (#849)

`string.find()` is defaulting to _pattern_ matching (rather than string
literal matching).  If you are using the `only_cwd` command in a
directory with a `-` (for example) the option fails to work.

This fix asks `string.find()` to interpret the arguments as literal
strings rather than patterns.

Reference: https://stackoverflow.com/a/15258515/181902
This commit is contained in:
Damon Timm
2021-05-16 14:36:16 -04:00
committed by GitHub
parent 4da66dab44
commit 69eb5eacff

View File

@@ -569,7 +569,7 @@ internal.buffers = function(opts)
if opts.ignore_current_buffer and b == vim.api.nvim_get_current_buf() then if opts.ignore_current_buffer and b == vim.api.nvim_get_current_buf() then
return false return false
end end
if opts.only_cwd and not string.find(vim.api.nvim_buf_get_name(b), vim.loop.cwd()) then if opts.only_cwd and not string.find(vim.api.nvim_buf_get_name(b), vim.loop.cwd(), 1, true) then
return false return false
end end
return true return true