Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(filter): insert path from filter.paths into self.paths #761

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dpetka2001
Copy link
Contributor

Description

Here we see that we insert the paths into filter instead of self.paths

self.paths = {}
local cwd = filter and filter.cwd
self.cwd = type(cwd) == "string" and cwd or opts.cwd or uv.cwd() or "."
self.cwd = vim.fs.normalize(self.cwd --[[@as string]], { _fast = true })
if not self.all and filter then
self.buf = filter.buf == true and 0 or filter.buf --[[@as number?]]
self.buf = self.buf == 0 and vim.api.nvim_get_current_buf() or self.buf
self.file = self.buf and vim.fs.normalize(vim.api.nvim_buf_get_name(self.buf), { _fast = true }) or nil
for path, want in pairs(filter.paths or {}) do
table.insert(filter, { path = vim.fs.normalize(path), want = want })
end

and later on here
if self.opts.paths then
for _, p in ipairs(self.paths) do
if (path:sub(1, #p.path) == p.path) ~= p.want then
return false
end
we check self.paths to get the path.

This was causing issues to not correctly filter out the already defined paths and I was able to see, for example the scratch buffer files in the pickers.

Related Issue(s)

None

Screenshots

@dpetka2001
Copy link
Contributor Author

dpetka2001 commented Jan 26, 2025

Another thing I noticed is that in the smart picker one has to redefine in his personal configuration the filter.paths from recent picker (otherwise I'm able to see the scratch buffers from stdpath("data")/scratch in the smart picker), presumably because there's something weird going on with the merge of the sources configs, since filter.paths is a list.

Unfortunately, my knowledge is limited and tried but couldn't quite understand what's going on with the way the merging is done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant