Skip to content

Commit

Permalink
fix(builtin.buffers): better buffer in cwd check (#2847)
Browse files Browse the repository at this point in the history
Previously, using `string.find`, certain characters were taken as regex
special characters leading to bad matches.
New approach takes bufname truncated to the length of cwd and compares
the two strings.

(cherry picked from commit 8b56e9b)
  • Loading branch information
jamestrew authored and Conni2461 committed Mar 6, 2024
1 parent 425ab66 commit 65ee034
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lua/telescope/builtin/__internal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,8 @@ internal.buffers = function(opts)
if cwd:sub(-1) ~= Path.path.sep then
cwd = cwd .. Path.path.sep
end
return vim.api.nvim_buf_get_name(bufnr):find(cwd) == nil
local bufname_prefix = vim.api.nvim_buf_get_name(bufnr):sub(1, #cwd)
return bufname_prefix ~= cwd
end

local bufnrs = vim.tbl_filter(function(bufnr)
Expand Down

0 comments on commit 65ee034

Please sign in to comment.