chore(watchers): Watcher shares single fs_event from Event, node watchers use unique path prefixed debounce context (#1453)

This commit is contained in:
Alexander Courtis
2022-07-26 18:43:58 +10:00
committed by GitHub
parent e5222970d9
commit eff1db341c
4 changed files with 156 additions and 84 deletions

View File

@@ -169,15 +169,17 @@ end
---Matching executable files in Windows.
---@param ext string
---@return boolean
local PATHEXT = vim.env.PATHEXT or ""
local wexe = vim.split(PATHEXT:gsub("%.", ""), ";")
local pathexts = {}
for _, v in pairs(wexe) do
pathexts[v] = true
end
function M.is_windows_exe(ext)
return pathexts[ext:upper()]
if not M.pathexts then
local PATHEXT = vim.env.PATHEXT or ""
local wexe = vim.split(PATHEXT:gsub("%.", ""), ";")
M.pathexts = {}
for _, v in pairs(wexe) do
M.pathexts[v] = true
end
end
return M.pathexts[ext:upper()]
end
function M.rename_loaded_buffers(old_path, new_path)
@@ -379,4 +381,23 @@ function M.clear_prompt()
end
end
-- return a new table with values from array
function M.array_shallow_clone(array)
local to = {}
for _, v in ipairs(array) do
table.insert(to, v)
end
return to
end
-- remove item from array if it exists
function M.array_remove(array, item)
for i, v in ipairs(array) do
if v == item then
table.remove(array, i)
break
end
end
end
return M