From 69eb5eacff421e05aeb1e02ff97ef64bfd955c53 Mon Sep 17 00:00:00 2001 From: Damon Timm Date: Sun, 16 May 2021 14:36:16 -0400 Subject: [PATCH] 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 --- lua/telescope/builtin/internal.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telescope/builtin/internal.lua b/lua/telescope/builtin/internal.lua index c412f69..2c4695f 100644 --- a/lua/telescope/builtin/internal.lua +++ b/lua/telescope/builtin/internal.lua @@ -569,7 +569,7 @@ internal.buffers = function(opts) if opts.ignore_current_buffer and b == vim.api.nvim_get_current_buf() then return false 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 end return true