diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-09-09 17:35:59 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-09-09 17:35:59 +0800 |
commit | 3267981ad105830ba115300597b449c047e12b09 (patch) | |
tree | f6d3fc267b0a7d4d95b2b4961a359c102f881392 | |
parent | 5f2417d1e23cbcf6c2d1b6bf5c488c7b99a2b628 (diff) | |
download | lua-language-server-3267981ad105830ba115300597b449c047e12b09.zip |
修正重复检查provide的问题
-rw-r--r-- | script-beta/core/completion.lua | 5 | ||||
-rw-r--r-- | test-beta/completion/init.lua | 19 |
2 files changed, 24 insertions, 0 deletions
diff --git a/script-beta/core/completion.lua b/script-beta/core/completion.lua index aac8bda4..351f09c3 100644 --- a/script-beta/core/completion.lua +++ b/script-beta/core/completion.lua @@ -424,9 +424,12 @@ local function checkProvideLocal(ast, word, start, results) if not block then return end + local used = {} guide.eachSourceType(block, 'getglobal', function (source) if source.start > start + and not used[source[1]] and matchKey(word, source[1]) then + used[source[1]] = true results[#results+1] = { label = source[1], kind = ckind.Variable, @@ -435,7 +438,9 @@ local function checkProvideLocal(ast, word, start, results) end) guide.eachSourceType(block, 'getlocal', function (source) if source.start > start + and not used[source[1]] and matchKey(word, source[1]) then + used[source[1]] = true results[#results+1] = { label = source[1], kind = ckind.Variable, diff --git a/test-beta/completion/init.lua b/test-beta/completion/init.lua index fb1f6373..30731a3c 100644 --- a/test-beta/completion/init.lua +++ b/test-beta/completion/init.lua @@ -315,6 +315,25 @@ local results (EXISTS) TEST [[ +local a$ + +local function f(fff) + fff = ast + fff = ast + fff = ast + fff = ast + fff = ast + fff = ast +end +]] +{ + { + label = 'ast', + kind = CompletionItemKind.Variable, + } +} + +TEST [[ t.a = {} t.b = {} t.$ |