diff options
-rw-r--r-- | server/src/core/document_symbol.lua | 25 | ||||
-rw-r--r-- | server/test/document_symbol/init.lua | 43 |
2 files changed, 46 insertions, 22 deletions
diff --git a/server/src/core/document_symbol.lua b/server/src/core/document_symbol.lua index b0802b9b..8e6fd01c 100644 --- a/server/src/core/document_symbol.lua +++ b/server/src/core/document_symbol.lua @@ -30,7 +30,7 @@ local SymbolKind = { TypeParameter = 26, } -local function buildFunc(vm, func, nextFunction, nextFinish) +local function buildFunc(vm, func) local source = func.source local declarat = func.declarat local name @@ -76,28 +76,9 @@ local function buildFunc(vm, func, nextFunction, nextFinish) end return function (vm) - local i = 0 - local function nextFunction() - i = i + 1 - local func = vm.results.funcs[i] - return func - end - - local function nextFinish() - local func = vm.results.funcs[i+1] - if not func then - return 0 - end - return func.source.finish - end - local symbols = {} - while true do - local func = nextFunction() - if not func then - break - end - symbols[#symbols+1] = buildFunc(vm, func, nextFunction, nextFinish) + for _, func in ipairs(vm.results.funcs) do + symbols[#symbols+1] = buildFunc(vm, func) end return symbols diff --git a/server/test/document_symbol/init.lua b/server/test/document_symbol/init.lua index 869e2939..c8f16fbd 100644 --- a/server/test/document_symbol/init.lua +++ b/server/test/document_symbol/init.lua @@ -153,3 +153,46 @@ end selectionRange = {13, 15}, } } + +--TEST [[ +--function A() +-- function A1() +-- end +-- function A2() +-- end +--end +--function B() +--end +--]] +--{ +-- [1] = { +-- name = 'A', +-- detail = 'function A()', +-- kind = SymbolKind.Function, +-- range = {1, 68}, +-- selectionRange = {10, 10}, +-- children = { +-- [1] = { +-- name = 'A1', +-- detail = 'function A1()', +-- kind = SymbolKind.Function, +-- range = {18, 38}, +-- selectionRange = {27, 28}, +-- }, +-- [2] = { +-- name = 'A2', +-- detail = 'function A2()', +-- kind = SymbolKind.Function, +-- range = {44, 64}, +-- selectionRange = {53, 54}, +-- }, +-- }, +-- }, +-- [2] = { +-- name = 'B', +-- detail = 'function B()', +-- kind = SymbolKind.Function, +-- range = {70, 85}, +-- selectionRange = {79, 79}, +-- }, +--} |