summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-01-02 09:38:10 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-01-02 09:38:10 +0800
commitf5f051c3fb1272c990c2074443877e55d3f6122e (patch)
tree7dca89b767cf3d2087c42c336be6b1a8fd9081f6
parent584b26c62fafe843c6ae618dba1350d07bf8f091 (diff)
downloadlua-language-server-f5f051c3fb1272c990c2074443877e55d3f6122e.zip
大纲的field能递归
-rw-r--r--server/src/core/document_symbol.lua8
-rw-r--r--server/test/document_symbol/init.lua35
2 files changed, 39 insertions, 4 deletions
diff --git a/server/src/core/document_symbol.lua b/server/src/core/document_symbol.lua
index e9d025db..13ee56e9 100644
--- a/server/src/core/document_symbol.lua
+++ b/server/src/core/document_symbol.lua
@@ -144,11 +144,11 @@ local function packChild(symbols, finish, kind)
end
symbols[#symbols] = nil
symbol.children = packChild(symbols, symbol.range[2], symbol.kind)
- if not t then
- t = {}
- end
- if symbol.kind == SymbolKind.Class and kind ~= SymbolKind.Variable then
+ if symbol.kind == SymbolKind.Class and kind == SymbolKind.Function then
else
+ if not t then
+ t = {}
+ end
t[#t+1] = symbol
end
end
diff --git a/server/test/document_symbol/init.lua b/server/test/document_symbol/init.lua
index edfd1a27..73e910cb 100644
--- a/server/test/document_symbol/init.lua
+++ b/server/test/document_symbol/init.lua
@@ -284,3 +284,38 @@ local t = {
}
}
}
+
+TEST [[
+local t = {
+ a = {
+ b = 1,
+ }
+}
+]]
+{
+ [1] = {
+ name = 't',
+ detail = EXISTS,
+ kind = SymbolKind.Variable,
+ range = {7, 44},
+ selectionRange = {7, 7},
+ children = {
+ [1] = {
+ name = 'a',
+ detail = EXISTS,
+ kind = SymbolKind.Class,
+ range = {17, 42},
+ selectionRange = {17, 17},
+ children = {
+ [1] = {
+ name = 'b',
+ detail = EXISTS,
+ kind = SymbolKind.Class,
+ range = {31, 31},
+ selectionRange = {31, 31},
+ }
+ }
+ },
+ }
+ }
+}