diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-12-02 17:48:41 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-12-02 17:48:41 +0800 |
commit | 3ab0c3bbb82e4aeb694cd0bc511fd3b43583c553 (patch) | |
tree | 184f9ac85f48d2c3dda45536693e4ef098b7f3c1 /script/core/completion/postfix.lua | |
parent | 9f236d0485ac4cee2b62261b84ef93f473596495 (diff) | |
download | lua-language-server-3ab0c3bbb82e4aeb694cd0bc511fd3b43583c553.zip |
fix postfix
Diffstat (limited to 'script/core/completion/postfix.lua')
-rw-r--r-- | script/core/completion/postfix.lua | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/script/core/completion/postfix.lua b/script/core/completion/postfix.lua index 9ad20965..0395e2a5 100644 --- a/script/core/completion/postfix.lua +++ b/script/core/completion/postfix.lua @@ -230,9 +230,10 @@ local accepts = { ['table'] = true, } -local function checkPostFix(state, word, wordPosition, position, results) +local function checkPostFix(state, word, wordPosition, position, symbol, results) local source = guide.eachSourceContain(state.ast, wordPosition, function (source) - if accepts[source.type] then + if accepts[source.type] + and source.finish == wordPosition then return source end end) @@ -249,14 +250,14 @@ local function checkPostFix(state, word, wordPosition, position, results) : add('lua', newText) : string(), textEdit = { - start = wordPosition + 1, + start = wordPosition + #symbol, finish = position, newText = newText, }, additionalTextEdits = { { start = source.start, - finish = wordPosition + 1, + finish = wordPosition + #symbol, newText = '', }, }, @@ -279,7 +280,7 @@ return function (state, position, results) local symbol = text:sub(offset, offset) if symbol == config.get 'Lua.completion.postfix' then local wordPosition = guide.offsetToPosition(state, offset - 1) - checkPostFix(state, word or '', wordPosition, position, results) + checkPostFix(state, word or '', wordPosition, position, symbol, results) return symbol ~= '.' and symbol ~= ':' end if not word then @@ -292,8 +293,8 @@ return function (state, position, results) offset = offset - 3 end if word then - local wordPosition = guide.offsetToPosition(state, offset - 1) - checkPostFix(state, word or '', wordPosition, position, results) + local wordPosition = guide.offsetToPosition(state, offset) + checkPostFix(state, word or '', wordPosition, position, '', results) return true end end |