diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-10-25 00:19:56 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-10-25 00:19:56 +0800 |
commit | a90a48c328045dd3f89da78a77f977ceb2cc7ae0 (patch) | |
tree | 26c55555aa74f32690bf8de9fa7d029c4cdd191e | |
parent | e9fa0071308c95d2d68bca410c4b12cbcab50e1f (diff) | |
download | lua-language-server-a90a48c328045dd3f89da78a77f977ceb2cc7ae0.zip |
completion checks visible
#1316
-rw-r--r-- | script/core/completion/completion.lua | 3 | ||||
-rw-r--r-- | test/completion/common.lua | 59 |
2 files changed, 62 insertions, 0 deletions
diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index a8909d06..4756edd6 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -566,6 +566,9 @@ local function checkFieldOfRefs(refs, state, word, startPos, position, parent, o if not matchKey(word, name, count >= 100) then goto CONTINUE end + if not vm.isVisible(parent, src) then + goto CONTINUE + end local funcLabel if config.get(state.uri, 'Lua.completion.showParams') then --- TODO determine if getlocal should be a function here too diff --git a/test/completion/common.lua b/test/completion/common.lua index cc164d3a..bf43a463 100644 --- a/test/completion/common.lua +++ b/test/completion/common.lua @@ -3904,3 +3904,62 @@ t.fff<??> kind = define.CompletionItemKind.Function, }, } + +TEST [[ +---@class A +---@field private x number +---@field y number + +---@type A +local t + +t.<??> +]] +{ + { + label = 'y', + kind = define.CompletionItemKind.Field, + }, +} + +TEST [[ +---@class A +---@field private x number +---@field protected y number +---@field z number + +---@class B: A +local t + +t.<??> +]] +{ + { + label = 'y', + kind = define.CompletionItemKind.Field, + }, + { + label = 'z', + kind = define.CompletionItemKind.Field, + }, +} + +TEST [[ +---@class A +---@field private x number +---@field protected y number +---@field z number + +---@class B: A + +---@type B +local t + +t.<??> +]] +{ + { + label = 'z', + kind = define.CompletionItemKind.Field, + }, +} |