diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-09-24 15:08:02 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-09-24 15:08:02 +0800 |
commit | 4b085b8aea5f33ec114baa31d2b9d72341383c32 (patch) | |
tree | fe35a326408e762711a31d3e803464f0c1a8468d /script/core/document-symbol.lua | |
parent | 0c8c6bbf23082d0b858646846a47a3001f718ae2 (diff) | |
parent | 35ce57976db3b4c42193279dd55972ea013fecad (diff) | |
download | lua-language-server-4b085b8aea5f33ec114baa31d2b9d72341383c32.zip |
Merge branch 'newparser'
Diffstat (limited to 'script/core/document-symbol.lua')
-rw-r--r-- | script/core/document-symbol.lua | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/script/core/document-symbol.lua b/script/core/document-symbol.lua index 9f950d25..cfabedab 100644 --- a/script/core/document-symbol.lua +++ b/script/core/document-symbol.lua @@ -5,20 +5,26 @@ local define = require 'proto.define' local util = require 'utility' local function buildName(source, text) + local uri = guide.getUri(source) + local state = files.getState(uri) + local startOffset = guide.positionToOffset(state, source.start) if source.type == 'setmethod' or source.type == 'getmethod' then if source.method then - return text:sub(source.start, source.method.finish) + local finishOffset = guide.positionToOffset(state, source.method.finish) + return text:sub(startOffset + 1, finishOffset) end end if source.type == 'setfield' or source.type == 'tablefield' or source.type == 'getfield' then if source.field then - return text:sub(source.start, source.field.finish) + local finishOffset = guide.positionToOffset(state, source.field.finish) + return text:sub(startOffset + 1, finishOffset) end end - return text:sub(source.start, source.finish) + local finishOffset = guide.positionToOffset(state, source.finish) + return text:sub(startOffset + 1, finishOffset) end local function buildFunctionParams(func) @@ -208,7 +214,7 @@ local function buildAnonymousFunction(source, text, used, symbols) detail = ('%sfunction (%s)'):format(head, buildFunctionParams(source)), kind = define.SymbolKind.Function, range = { source.start, source.finish }, - selectionRange = { source.start, source.start }, + selectionRange = { source.keyword[1], source.keyword[2] }, valueRange = { source.start, source.finish }, } end |