diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-09-08 23:42:52 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-09-08 23:42:52 +0800 |
commit | 9a050f2aa27dc026d0121b80084fb68093c37ac8 (patch) | |
tree | 1ddf9f7d719a732b92c5c1db8dba21146f93c0a1 /script-beta/core/completion.lua | |
parent | 1dfee9623937c0619b3aaf3e2139afcc14351042 (diff) | |
download | lua-language-server-9a050f2aa27dc026d0121b80084fb68093c37ac8.zip |
exp的情况
Diffstat (limited to 'script-beta/core/completion.lua')
-rw-r--r-- | script-beta/core/completion.lua | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index 24efbf7b..7ddc2c95 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -713,21 +713,37 @@ local function checkLenPlusOne(ast, text, offset, results) if not matchKey(writingText, nodeText) then return end - local eq = text:find('%s*%=', source.node.finish) - local label = text:match('%#[ \t]*', pos) .. nodeText .. '+1' - local newText = label .. ']' - if not eq then - newText = newText .. ' = ' + if source.parent == guide.getParentBlock(source) then + -- state + local label = text:match('%#[ \t]*', pos) .. nodeText .. '+1' + local eq = text:find('%s*%=', source.node.finish) + local newText = label .. ']' + if not eq then + newText = newText .. ' = ' + end + results[#results+1] = { + label = label, + kind = ckind.Snippet, + textEdit = { + start = pos, + finish = source.finish, + newText = newText, + }, + } + else + -- exp + local label = text:match('%#[ \t]*', pos) .. nodeText + local newText = label .. ']' + results[#results+1] = { + label = label, + kind = ckind.Snippet, + textEdit = { + start = pos, + finish = source.finish, + newText = newText, + }, + } end - results[#results+1] = { - label = label, - kind = ckind.Snippet, - textEdit = { - start = pos, - finish = source.finish, - newText = newText, - }, - } end end) end |