fix: willRename source path (#248)

* fix: willRename source path

* update: path matching handling

* lint: apply stylua

---------

Co-authored-by: Steven Arcangeli <506791+stevearc@users.noreply.github.com>
This commit is contained in:
Luckas 2023-12-10 22:41:12 +03:00 committed by GitHub
parent 1fce168881
commit 24027ed8d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -13,6 +13,16 @@ local function file_matches(filepath, pattern)
return false
end
end
if vim.lsp._watchfiles then
local glob = pattern.glob
local path = filepath
if vim.tbl_get(pattern, "options", "ignoreCase") then
glob, path = glob:lower(), path:lower()
end
return vim.lsp._watchfiles._match(glob, path)
end
local pat = vim.fn.glob2regpat(pattern.glob)
if vim.tbl_get(pattern, "options", "ignoreCase") then
pat = "\\c" .. pat
@ -49,7 +59,7 @@ local function get_matching_paths(client, path_pairs)
for _, pair in ipairs(path_pairs) do
if fs.is_subpath(client.config.root_dir, pair.src) then
local relative_file = pair.src:sub(client.config.root_dir:len() + 2)
if any_match(relative_file, filters) then
if any_match(pair.src, filters) or any_match(relative_file, filters) then
table.insert(ret, pair)
end
end