9494--- @param name string
9595--- @param isScopeDiag boolean
9696--- @param response async fun ( result : any )
97+ --- @param ignoreFileOpenState ? boolean
9798--- @return boolean
98- local function check (uri , name , isScopeDiag , response )
99+ local function check (uri , name , isScopeDiag , response , ignoreFileOpenState )
99100 local disables = config .get (uri , ' Lua.diagnostics.disable' )
100101 if util .arrayHas (disables , name ) then
101102 return false
@@ -107,7 +108,7 @@ local function check(uri, name, isScopeDiag, response)
107108 return false
108109 end
109110
110- if status == ' Opened' and not files .isOpen (uri ) then
111+ if not ignoreFileOpenState and status == ' Opened' and not files .isOpen (uri ) then
111112 return false
112113 end
113114
167168--- @param isScopeDiag boolean
168169--- @param response async fun ( result : any )
169170--- @param checked ? async fun ( name : string )
170- return function (uri , isScopeDiag , response , checked )
171+ --- @param ignoreFileOpenState ? boolean
172+ return function (uri , isScopeDiag , response , checked , ignoreFileOpenState )
171173 local ast = files .getState (uri )
172174 if not ast then
173175 return nil
@@ -176,7 +178,7 @@ return function (uri, isScopeDiag, response, checked)
176178 for _ , name in ipairs (buildDiagList ()) do
177179 await .delay ()
178180 local clock = os.clock ()
179- local suc = check (uri , name , isScopeDiag , response )
181+ local suc = check (uri , name , isScopeDiag , response , ignoreFileOpenState )
180182 if suc then
181183 local cost = os.clock () - clock
182184 diagCosts [name ] = (diagCosts [name ] or 0 ) + cost
0 commit comments