summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorCppCXY <812125110@qq.com>2022-02-22 14:10:21 +0800
committerCppCXY <812125110@qq.com>2022-02-22 14:10:21 +0800
commitc920f9630e5a1aa88c993ad22e786a2f9232b21e (patch)
treee59992179500dc3b0bb961b4033be350cd5420a5 /script
parentaa13abab66752f42081f8d61d7fb415d03953364 (diff)
parentd57c21e585e7285583b7379e9e955da3b1345508 (diff)
downloadlua-language-server-c920f9630e5a1aa88c993ad22e786a2f9232b21e.zip
Merge branch 'master' of https://github.com/sumneko/lua-language-server
Diffstat (limited to 'script')
-rw-r--r--script/core/noder.lua6
-rw-r--r--script/provider/provider.lua5
-rw-r--r--script/service/telemetry.lua11
-rw-r--r--script/vm/getDocs.lua3
-rw-r--r--script/workspace/require-path.lua3
-rw-r--r--script/workspace/workspace.lua1
6 files changed, 21 insertions, 8 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua
index 0a04a744..fcc6b6f4 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -186,7 +186,11 @@ local function getFieldEventName(field)
if not secondTypeUnit or secondTypeUnit.type ~= 'doc.type.function' then
return nil
end
- local eventName = firstEnum[1]:match [[^['"](.+)['"]$]]
+ local enmuStr = firstEnum[1]
+ if type(enmuStr) ~= 'string' then
+ return nil
+ end
+ local eventName = enmuStr:match [[^['"](.+)['"]$]]
field._eventName = eventName
return eventName
end
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index f516e1af..3e8fec24 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -425,10 +425,11 @@ m.register 'textDocument/documentHighlight' {
capability = {
documentHighlightProvider = true,
},
- abortByFileUpdate = true,
+ ---@async
function (params)
local core = require 'core.highlight'
local uri = files.getRealUri(params.textDocument.uri)
+ workspace.awaitReady(uri)
if not files.exists(uri) then
return nil
end
@@ -927,11 +928,11 @@ m.register 'textDocument/foldingRange' {
capability = {
foldingRangeProvider = true,
},
- abortByFileUpdate = true,
---@async
function (params)
local core = require 'core.folding'
local uri = files.getRealUri(params.textDocument.uri)
+ workspace.awaitReady(uri)
if not files.exists(uri) then
return nil
end
diff --git a/script/service/telemetry.lua b/script/service/telemetry.lua
index d1bf7680..2d956ed0 100644
--- a/script/service/telemetry.lua
+++ b/script/service/telemetry.lua
@@ -60,16 +60,17 @@ local function pushVersion(link)
end
local function occlusionPath(str)
- return str:gsub('[^"\r\n]+', function (chunk)
+ return str:gsub('(%s*)([^:"\'\r\n]+)', function (left, chunk)
if not chunk:find '[/\\]' then
return
end
local newStr, count = chunk:gsub('.+([/\\]script[/\\])', '***%1')
if count > 0 then
- return newStr
- elseif chunk:find '^%u:'
- or chunk:sub(1, 1) == '/' then
- return '***'
+ return left .. newStr
+ elseif chunk:sub(1, 1) == '\\'
+ or chunk:sub(1, 1) == '/'
+ or chunk:sub(1, 3) == '...' then
+ return left .. '***'
end
end)
end
diff --git a/script/vm/getDocs.lua b/script/vm/getDocs.lua
index 59651ee9..4aeda446 100644
--- a/script/vm/getDocs.lua
+++ b/script/vm/getDocs.lua
@@ -11,6 +11,9 @@ local noder = require 'core.noder'
---@param name? string
---@return parser.guide.object[]
function vm.getDocDefines(uri, name)
+ if type(name) ~= 'string' then
+ return {}
+ end
local cache = vm.getCache 'getDocDefines'
if cache[name] then
return cache[name]
diff --git a/script/workspace/require-path.lua b/script/workspace/require-path.lua
index f0a75eb1..56c94424 100644
--- a/script/workspace/require-path.lua
+++ b/script/workspace/require-path.lua
@@ -148,6 +148,9 @@ end
local function removeVisiblePath(uri)
local path = furi.decode(uri)
path = workspace.normalize(path)
+ if not path then
+ return
+ end
for _, scp in ipairs(workspace.folders) do
scp:get('visiblePath')[path] = nil
---@type collector
diff --git a/script/workspace/workspace.lua b/script/workspace/workspace.lua
index cb8bd68b..80df7d9c 100644
--- a/script/workspace/workspace.lua
+++ b/script/workspace/workspace.lua
@@ -234,6 +234,7 @@ end
---@async
function m.awaitLoadFile(uri)
+ m.awaitReady(uri)
local scp = scope.getScope(uri)
local ld <close> = loading.create(scp)
local native = m.getNativeMatcher(scp)