summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-12 12:58:43 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-12 12:58:43 +0800
commitf1c1debb06035e2b9c11cb0a8486d14561bfc066 (patch)
treee107804918ff353c1b16a3832237b77c8a7bb867 /server
parent650f1982d237282fecac43ba6362ec75302d91a1 (diff)
downloadlua-language-server-f1c1debb06035e2b9c11cb0a8486d14561bfc066.zip
修正bug
Diffstat (limited to 'server')
-rw-r--r--server/src/core/document_symbol.lua4
-rw-r--r--server/test/document_symbol/init.lua14
2 files changed, 16 insertions, 2 deletions
diff --git a/server/src/core/document_symbol.lua b/server/src/core/document_symbol.lua
index dd18ac23..18af9ceb 100644
--- a/server/src/core/document_symbol.lua
+++ b/server/src/core/document_symbol.lua
@@ -57,7 +57,7 @@ local function buildLocal(vm, source, callback)
-- 由于范围不允许交叉,为了支持 local x, y, z = 1, 2, 3 的形式
-- 范围只能限定在变量上
-- 而 local function xx() 的形式范围会包含整个 function
- if source.start > valueSource.start then
+ if source.start > valueSource.start and source.finish < valueSource.finish then
callback {
name = name,
detail = hvr.label:gsub('[\r\n]', ''),
@@ -111,7 +111,7 @@ local function buildSet(vm, source, callback)
-- 由于范围不允许交叉,为了支持 x, y, z = 1, 2, 3 的形式
-- 范围只能限定在变量上
-- 而 function xx() 的形式范围会包含整个 function
- if source.start > valueSource.start then
+ if source.start > valueSource.start and source.finish < valueSource.finish then
callback {
name = name,
-- 前端不支持多行
diff --git a/server/test/document_symbol/init.lua b/server/test/document_symbol/init.lua
index f73cd6ba..fb75c3a7 100644
--- a/server/test/document_symbol/init.lua
+++ b/server/test/document_symbol/init.lua
@@ -61,6 +61,19 @@ local function eq(a, b)
return a == b
end
+local function checkArcoss(symbols)
+ local lastFinish = 0
+ for _, symbol in ipairs(symbols) do
+ assert(symbol.range[1] <= symbol.selectionRange[1])
+ assert(symbol.range[2] >= symbol.selectionRange[2])
+ assert(symbol.range[2] > lastFinish)
+ lastFinish = symbol.range[2]
+ if symbol.children then
+ checkArcoss(symbol.children)
+ end
+ end
+end
+
function TEST(script)
return function (expect)
local ast = parser:ast(script)
@@ -68,6 +81,7 @@ function TEST(script)
assert(vm)
local result = core.documentSymbol(vm)
assert(eq(expect, result))
+ checkArcoss(result)
end
end