fix: #18 Replace directory pattern match with exact match

* fix: #18 replace directory pattern match with exact match

* fix: #18 properly expand directory name
main
HumblePresent 2022-08-13 04:58:03 -05:00 committed by GitHub
parent b70eb5317d
commit 6ce6823643
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -27,14 +27,14 @@ function M.get_last_item(table)
end
---Check if a target directory exists in a given table
---@param dir_target string
---@param dir_table table
---@param dir string
---@param dirs_table table
---@return boolean
function M.dirs_match(dir, dirs_table)
local dir = vim.fn.expand(dir)
dir = vim.fn.expand(dir)
return dirs_table
and next(vim.tbl_filter(function(pattern)
return dir:match(vim.fn.expand(pattern))
and next(vim.tbl_filter(function(dir_match)
return dir == vim.fn.expand(dir_match)
end, dirs_table))
end