fix(llm_tools): Improve the permissions logic (#2506)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
@@ -111,7 +111,11 @@ end
|
|||||||
function M.has_permission_to_access(abs_path)
|
function M.has_permission_to_access(abs_path)
|
||||||
if not Path:new(abs_path):is_absolute() then return false end
|
if not Path:new(abs_path):is_absolute() then return false end
|
||||||
local project_root = Utils.get_project_root()
|
local project_root = Utils.get_project_root()
|
||||||
if abs_path:sub(1, #project_root) ~= project_root then return false end
|
-- allow if inside project root OR inside user config dir
|
||||||
|
local config_dir = vim.fn.stdpath("config")
|
||||||
|
local in_project = abs_path:sub(1, #project_root) == project_root
|
||||||
|
local in_config = abs_path:sub(1, #config_dir) == config_dir
|
||||||
|
if not in_project and not in_config then return false end
|
||||||
return not M.is_ignored(abs_path)
|
return not M.is_ignored(abs_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user