summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-09-27 17:17:11 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-09-27 17:17:11 +0800
commit98c74b1f9a04ed49e4c9186e9e01f7c5c15449c9 (patch)
treefa251ce2f84416923e465e04d6627a53edd2bcec /script/core
parent7344986f6bcc7891e60d23396eaf3ee130c435e3 (diff)
downloadlua-language-server-98c74b1f9a04ed49e4c9186e9e01f7c5c15449c9.zip
fix
Diffstat (limited to 'script/core')
-rw-r--r--script/core/completion.lua11
1 files changed, 10 insertions, 1 deletions
diff --git a/script/core/completion.lua b/script/core/completion.lua
index bb55506a..347b1186 100644
--- a/script/core/completion.lua
+++ b/script/core/completion.lua
@@ -62,8 +62,17 @@ local function findNearestSource(state, position)
end
local function findNearestTableField(state, position)
+ local uri = state.uri
+ local text = files.getText(uri)
+ local offset = guide.positionToOffset(state, position)
+ local soffset = lookBackward.findAnyOffset(text, offset - 1)
+ local symbol = text:sub(soffset, soffset)
+ if symbol == '}' then
+ return nil
+ end
+ local sposition = guide.offsetToPosition(state, soffset)
local source
- guide.eachSourceContain(state.ast, position, function (src)
+ guide.eachSourceContain(state.ast, sposition, function (src)
if src.type == 'table'
or src.type == 'tablefield'
or src.type == 'tableindex'