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: do not pass sanitized directories into utils.dirs_match #148

Merged
merged 3 commits into from
Aug 17, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions lua/persisted/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,18 @@ function M.fire(event)
vim.api.nvim_exec_autocmds("User", { pattern = "Persisted" .. event })
end

---Get the current working directory
---@return string
function M.cwd()
return utils.sanitize_dir(vim.fn.getcwd())
end

---Get the current session for the current working directory and git branch
---@param opts? {branch?: boolean}
---@return string
function M.current(opts)
opts = opts or {}
local name = M.cwd()
local name = utils.sanitize_dir(vim.fn.getcwd())

if config.use_git_branch and opts.branch ~= false then
local branch = M.branch()
if branch then
name = name .. "@@" .. branch:gsub("[\\/:]+", "%%")
branch = utils.sanitize_dir(branch)
name = name .. "@@" .. branch
end
end

Expand Down Expand Up @@ -164,7 +159,7 @@ function M.allowed_dir(opts)
end

opts = opts or {}
local dir = opts.dir or M.cwd()
local dir = opts.dir or vim.fn.getcwd()

return utils.dirs_match(dir, config.allowed_dirs) and not utils.dirs_match(dir, config.ignored_dirs)
end
Expand Down