diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-09-24 11:11:31 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-09-24 11:11:31 +0800 |
commit | b43dc72c536b99e4ce74eb1cfe88e2cea91fe593 (patch) | |
tree | 2232cc7f9c12cfea4242c04b23ce7682d4d49896 /script-beta/core | |
parent | 33eea9604c870d5b1daa59a5a5b892c4be3572c1 (diff) | |
download | lua-language-server-b43dc72c536b99e4ce74eb1cfe88e2cea91fe593.zip |
更新文件符号
Diffstat (limited to 'script-beta/core')
-rw-r--r-- | script-beta/core/document-symbol.lua | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/script-beta/core/document-symbol.lua b/script-beta/core/document-symbol.lua index 629c89d0..2aeb3ae1 100644 --- a/script-beta/core/document-symbol.lua +++ b/script-beta/core/document-symbol.lua @@ -26,7 +26,7 @@ local function buildFunction(source, symbols) local range, kind if func.start > source.finish then -- a = function() - range = { source.start, source.finish } + range = { source.start, func.finish } else -- function f() range = { func.start, func.finish } @@ -62,33 +62,39 @@ end local function buildValue(source, symbols) local name = lname(source) - local range, valueRange, kind + local range, sRange, valueRange, kind local details = {} if source.type == 'local' then if source.parent.type == 'funcargs' then details[1] = 'param ' range = { source.start, source.finish } + sRange = { source.start, source.finish } kind = skind.Constant else details[1] = 'local ' range = { source.start, source.finish } + sRange = { source.start, source.finish } kind = skind.Variable end elseif source.type == 'setlocal' then details[1] = 'setlocal ' range = { source.start, source.finish } + sRange = { source.start, source.finish } kind = skind.Variable elseif source.type == 'setglobal' then details[1] = 'global ' range = { source.start, source.finish } + sRange = { source.start, source.finish } kind = skind.Constant elseif source.type == 'tablefield' then details[1] = 'field ' range = { source.field.start, source.field.finish } + sRange = { source.field.start, source.field.finish } kind = skind.Property else details[1] = 'field ' range = { source.field.start, source.field.finish } + sRange = { source.field.start, source.field.finish } kind = skind.Field end details[2] = name @@ -117,6 +123,7 @@ local function buildValue(source, symbols) details[4] = buildTable(source.value) details[5] = '}' end + range = { range[1], source.value.finish } valueRange = { source.value.start, source.value.finish } else valueRange = range @@ -126,7 +133,7 @@ local function buildValue(source, symbols) detail = table.concat(details), kind = kind, range = range, - selectionRange = range, + selectionRange = sRange, valueRange = valueRange, } end @@ -195,7 +202,7 @@ end local function packSymbols(symbols) -- 按照start位置反向排序 table.sort(symbols, function (a, b) - return a.range[1] > b.range[1] + return a.selectionRange[1] > b.selectionRange[1] end) -- 处理嵌套 return packChild(symbols, math.maxinteger) |