diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-10-21 20:14:35 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-10-21 20:14:35 +0800 |
commit | 9791565324f0376494600ee230da7cdcb42a3310 (patch) | |
tree | d53e235209dc14cbf60e255d5771e4c5f94192d5 | |
parent | 9cbeeb3828143a22cda1a3e631e30df8fb2242d9 (diff) | |
download | lua-language-server-9791565324f0376494600ee230da7cdcb42a3310.zip |
catch error
-rw-r--r-- | script/filewatch.lua | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/script/filewatch.lua b/script/filewatch.lua index e8c54d62..17a0548b 100644 --- a/script/filewatch.lua +++ b/script/filewatch.lua @@ -5,6 +5,16 @@ local await = require 'await' local MODIFY = 1 << 0 local RENAME = 1 << 1 +local function exists(filename) + local path = fs.path(filename) + local suc, res = pcall(fs.exists, path) + if suc and res then + return true + else + return false + end +end + ---@class filewatch local m = {} @@ -53,7 +63,7 @@ function m.update() local changes = {} for path, flag in pairs(collect) do if flag & RENAME ~= 0 then - if fs.exists(fs.path(path)) then + if exists(path) then changes[#changes+1] = { type = 'create', path = path, |