diff options
author | sumneko <sumneko@hotmail.com> | 2021-12-02 22:16:18 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2021-12-02 22:16:18 +0800 |
commit | c47baf932309a05673b7931fdf6a1be207fb7bc4 (patch) | |
tree | 2869d38a1472045ee9075083d14ca31ae6b35dd1 /script/core/completion/postfix.lua | |
parent | b6da7274e8fa773183146982f8864247bb33a214 (diff) | |
parent | cb2042160865589b5534a6bf0b6c366ae4ab1d99 (diff) | |
download | lua-language-server-c47baf932309a05673b7931fdf6a1be207fb7bc4.zip |
Merge remote-tracking branch 'origin/master' into multi-workspace
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 08b3feac..b2b777e7 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(nil, '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 |