summaryrefslogtreecommitdiff
path: root/script-beta/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-09-17 21:55:21 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-09-17 21:55:21 +0800
commit0b506b224b567da58b739c6bfd29a5db47c089b3 (patch)
tree6da4213bc7f7fd8f329bdd07b78a6b6e377c310f /script-beta/core
parent3da564e159b2a1051acb364ad65ae7d7745e1013 (diff)
downloadlua-language-server-0b506b224b567da58b739c6bfd29a5db47c089b3.zip
支持变形为 _ENV['xxx'] 的形式
Diffstat (limited to 'script-beta/core')
-rw-r--r--script-beta/core/completion.lua36
1 files changed, 20 insertions, 16 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua
index 27dc35ba..4df1be5b 100644
--- a/script-beta/core/completion.lua
+++ b/script-beta/core/completion.lua
@@ -286,23 +286,27 @@ local function checkFieldFromFieldToIndex(name, parent, word, start, offset)
newText = ('[%q]'):format(name),
}
local nxt = parent.next
- local dotStart
- if nxt.type == 'setfield'
- or nxt.type == 'getfield'
- or nxt.type == 'tablefield' then
- dotStart = nxt.dot.start
- elseif nxt.type == 'setmethod'
- or nxt.type == 'getmethod' then
- dotStart = nxt.colon.start
- end
- if dotStart then
- additionalTextEdits = {
- {
- start = dotStart,
- finish = dotStart,
- newText = '',
+ if nxt then
+ local dotStart
+ if nxt.type == 'setfield'
+ or nxt.type == 'getfield'
+ or nxt.type == 'tablefield' then
+ dotStart = nxt.dot.start
+ elseif nxt.type == 'setmethod'
+ or nxt.type == 'getmethod' then
+ dotStart = nxt.colon.start
+ end
+ if dotStart then
+ additionalTextEdits = {
+ {
+ start = dotStart,
+ finish = dotStart,
+ newText = '',
+ }
}
- }
+ end
+ else
+ textEdit.newText = '_ENV' .. textEdit.newText
end
return textEdit, additionalTextEdits
end