From a90a48c328045dd3f89da78a77f977ceb2cc7ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 25 Oct 2022 00:19:56 +0800 Subject: completion checks visible #1316 --- script/core/completion/completion.lua | 3 ++ test/completion/common.lua | 59 +++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) 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, + }, +} -- cgit v1.2.3