summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-10 02:27:49 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-10 02:27:49 +0800
commit528c8073b4785a2a0cfd80466357d2ba252ed950 (patch)
treeacf67e5980e6b63a1e96e759adab361470284a2b /script
parenta3f5b1ceb2b6722a28671cb6e2633b3fc0ae6713 (diff)
downloadlua-language-server-528c8073b4785a2a0cfd80466357d2ba252ed950.zip
fix #1027
Diffstat (limited to 'script')
-rw-r--r--script/files.lua15
1 files changed, 9 insertions, 6 deletions
diff --git a/script/files.lua b/script/files.lua
index 682f630f..2ddb00d6 100644
--- a/script/files.lua
+++ b/script/files.lua
@@ -35,8 +35,8 @@ end
m.reset()
-local fixedUri = {}
---- 获取文件的真实uri
+local uriMap = {}
+-- 获取文件的真实uri,但不穿透软链接
---@param uri uri
---@return uri
function m.getRealUri(uri)
@@ -47,16 +47,19 @@ function m.getRealUri(uri)
return uri
end
suc, res = pcall(fs.canonical, path)
- if not suc or res:string():gsub('/', '\\') == filename then
+ if not suc then
return uri
end
filename = res:string()
local ruri = furi.encode(filename)
- if uri ~= ruri and not fixedUri[ruri] then
- fixedUri[ruri] = true
+ if uri == ruri then
+ return ruri
+ end
+ if not uriMap[ruri] then
+ uriMap[ruri] = uri
log.warn(('Fix real file uri: %s -> %s'):format(uri, ruri))
end
- return ruri
+ return uriMap[ruri]
end
--- 打开文件