summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-10-21 20:14:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-10-21 20:14:35 +0800
commit9791565324f0376494600ee230da7cdcb42a3310 (patch)
treed53e235209dc14cbf60e255d5771e4c5f94192d5
parent9cbeeb3828143a22cda1a3e631e30df8fb2242d9 (diff)
downloadlua-language-server-9791565324f0376494600ee230da7cdcb42a3310.zip
catch error
-rw-r--r--script/filewatch.lua12
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,