From 289a780f38c24a7ee0f4ca9502214b41fe11fc30 Mon Sep 17 00:00:00 2001 From: sumneko Date: Wed, 3 Apr 2019 19:13:01 +0800 Subject: =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=AE=8C=E6=88=90=E7=9A=84=20child?= =?UTF-8?q?=20=E8=BF=87=E6=BB=A4=E5=85=B3=E9=94=AE=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/core/completion.lua | 13 ++++++++++++- server/test/completion/init.lua | 11 +++++++---- server/test/diagnostics/init.lua | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) (limited to 'server') diff --git a/server/src/core/completion.lua b/server/src/core/completion.lua index 2204c369..83f684f3 100644 --- a/server/src/core/completion.lua +++ b/server/src/core/completion.lua @@ -30,6 +30,12 @@ local CompletionItemKind = { TypeParameter = 25, } +local KEYS = {'and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', 'goto', 'if', 'in', 'local', 'nil', 'not', 'or', 'repeat', 'return', 'then', 'true', 'until', 'while', 'toclose'} +local KEYMAP = {} +for _, k in ipairs(KEYS) do + KEYMAP[k] = true +end + local function matchKey(me, other) if me == other then return true @@ -223,6 +229,9 @@ local function searchFields(vm, source, word, callback) if map[k] then return end + if KEYMAP[k] then + return + end if info.type ~= 'set child' and info.type ~= 'get child' then return end @@ -244,6 +253,9 @@ local function searchFields(vm, source, word, callback) if map[k] then return end + if KEYMAP[k] then + return + end if not v:getLib() then return end @@ -292,7 +304,6 @@ local function searchCloseGlobal(vm, source, word, callback) end) end -local KEYS = {'and', 'break', 'do', 'else', 'elseif', 'end', 'false', 'for', 'function', 'goto', 'if', 'in', 'local', 'nil', 'not', 'or', 'repeat', 'return', 'then', 'true', 'until', 'while', 'toclose'} local function searchKeyWords(vm, source, word, callback) for _, key in ipairs(KEYS) do if matchKey(word, key) then diff --git a/server/test/completion/init.lua b/server/test/completion/init.lua index b34d567d..2f965bcb 100644 --- a/server/test/completion/init.lua +++ b/server/test/completion/init.lua @@ -700,10 +700,6 @@ end label = 'b', kind = CompletionItemKind.Field, }, - { - label = 'end', - kind = CompletionItemKind.Field, - }, } TEST [[ @@ -731,3 +727,10 @@ TEST [[ function table.i@ ]] (EXISTS) + +TEST [[ +do + xx.@ +end +]] +(nil) diff --git a/server/test/diagnostics/init.lua b/server/test/diagnostics/init.lua index f1efca70..dc060ba4 100644 --- a/server/test/diagnostics/init.lua +++ b/server/test/diagnostics/init.lua @@ -245,4 +245,4 @@ ROOT = 1 TEST [[ local f = load('') f(1, 2, 3) -]] \ No newline at end of file +]] -- cgit v1.2.3