summaryrefslogtreecommitdiff
path: root/script/files.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-01-27 16:59:05 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-01-27 16:59:05 +0800
commite72f5143dc1d2d41763b74809b1ffe5ec5f426c2 (patch)
tree50065e80f626ab286795e13c4cdfa195305be31f /script/files.lua
parent219c802e4e6a67aa9c4a1b4a5bd7886f8181b7c4 (diff)
downloadlua-language-server-e72f5143dc1d2d41763b74809b1ffe5ec5f426c2.zip
fix modifying the code before loading finish
Diffstat (limited to 'script/files.lua')
-rw-r--r--script/files.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/script/files.lua b/script/files.lua
index 1e7c15e9..7e14bd9c 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -122,7 +122,7 @@ end
--- 设置文件文本
---@param uri uri
---@param text string
-function m.setText(uri, text)
+function m.setText(uri, text, isTrust)
if not text then
return
end
@@ -139,11 +139,15 @@ function m.setText(uri, text)
m._pairsCache = nil
end
local file = m.fileMap[uri]
+ if file.trusted and not isTrust then
+ return
+ end
local newText = pluginOnSetText(file, text)
if file.text == newText then
return
end
file.text = newText
+ file.trusted = isTrust
file.originText = text
m.linesMap[uri] = nil
m.originLinesMap[uri] = nil