diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-03-15 18:42:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-03-15 18:42:49 +0800 |
commit | 20d4be8bc74d6a78372f50112288fb6c4406b841 (patch) | |
tree | 0cac43175674535150e72da3abafe695b586eda0 | |
parent | d1363a89da92c3112820da25914d63cb718f65cf (diff) | |
download | lua-language-server-20d4be8bc74d6a78372f50112288fb6c4406b841.zip |
use real path in scanning
non-Windows also check real path
-rw-r--r-- | script/files.lua | 5 | ||||
-rw-r--r-- | script/workspace/workspace.lua | 15 |
2 files changed, 10 insertions, 10 deletions
diff --git a/script/files.lua b/script/files.lua index bd533c35..9ddc5039 100644 --- a/script/files.lua +++ b/script/files.lua @@ -36,13 +36,10 @@ end m.reset() local fixedUri = {} ---- 获取文件的真实uri(真实大小写) +--- 获取文件的真实uri ---@param uri uri ---@return uri function m.getRealUri(uri) - if platform.OS ~= 'Windows' then - return uri - end local filename = furi.decode(uri) local path = fs.path(filename) local suc, res = pcall(fs.exists, path) diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua index 80df7d9c..934c0735 100644 --- a/script/workspace/workspace.lua +++ b/script/workspace/workspace.lua @@ -241,8 +241,9 @@ function m.awaitLoadFile(uri) log.info('Scan files at:', uri) ---@async native:scan(furi.decode(uri), function (path) - scp:get('cachedUris')[furi.encode(path)] = true - ld:loadFile(furi.encode(path)) + local uri = files.getRealUri(furi.encode(path)) + scp:get('cachedUris')[uri] = true + ld:loadFile(uri) end) ld:loadAll() end @@ -282,8 +283,9 @@ function m.awaitPreload(scp) log.info('Scan files at:', scp:getName()) ---@async native:scan(furi.decode(scp.uri), function (path) - scp:get('cachedUris')[furi.encode(path)] = true - ld:loadFile(furi.encode(path)) + local uri = files.getRealUri(furi.encode(path)) + scp:get('cachedUris')[uri] = true + ld:loadFile(uri) end) end @@ -292,8 +294,9 @@ function m.awaitPreload(scp) scp:addLink(libMatcher.uri) ---@async libMatcher.matcher:scan(furi.decode(libMatcher.uri), function (path) - scp:get('cachedUris')[furi.encode(path)] = true - ld:loadFile(furi.encode(path), libMatcher.uri) + local uri = files.getRealUri(furi.encode(path)) + scp:get('cachedUris')[uri] = true + ld:loadFile(uri, libMatcher.uri) end) scp:gc(fw.watch(furi.decode(libMatcher.uri))) end |