Skip to content

Commit 1f93575

Browse files
committed
resolve #1558 detect multi libraries
1 parent fba6856 commit 1f93575

File tree

2 files changed

+38
-40
lines changed

2 files changed

+38
-40
lines changed

Diff for: changelog.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# changelog
22

3+
## 3.6.0
4+
* `CHG` detect multi libraries [#1558](https://github.com/sumneko/lua-language-server/issues/1558)
5+
36
## 3.5.6
47
`2022-9-16`
58
* `FIX` [#1439](https://github.com/sumneko/lua-language-server/issues/1439)

Diff for: script/library.lua

+35-40
Original file line numberDiff line numberDiff line change
@@ -383,13 +383,13 @@ local function apply3rd(uri, cfg, onlyMemory)
383383
client.setConfig(changes, onlyMemory)
384384
end
385385

386-
local hasAsked
386+
local hasAsked = {}
387387
---@async
388388
local function askFor3rd(uri, cfg)
389-
if hasAsked then
389+
if hasAsked[cfg.name] then
390390
return nil
391391
end
392-
hasAsked = true
392+
hasAsked[cfg.name] = true
393393
local yes1 = lang.script.WINDOW_APPLY_WHIT_SETTING
394394
local yes2 = lang.script.WINDOW_APPLY_WHITOUT_SETTING
395395
local no = lang.script.WINDOW_DONT_SHOW_AGAIN
@@ -402,24 +402,8 @@ local function askFor3rd(uri, cfg)
402402
end
403403
if result == yes1 then
404404
apply3rd(uri, cfg, false)
405-
client.setConfig({
406-
{
407-
key = 'Lua.workspace.checkThirdParty',
408-
action = 'set',
409-
value = false,
410-
uri = uri,
411-
},
412-
}, false)
413405
elseif result == yes2 then
414406
apply3rd(uri, cfg, true)
415-
client.setConfig({
416-
{
417-
key = 'Lua.workspace.checkThirdParty',
418-
action = 'set',
419-
value = false,
420-
uri = uri,
421-
},
422-
}, true)
423407
else
424408
client.setConfig({
425409
{
@@ -450,9 +434,6 @@ local function wholeMatch(a, b)
450434
end
451435

452436
local function check3rdByWords(uri, configs)
453-
if hasAsked then
454-
return
455-
end
456437
if not files.isLua(uri) then
457438
return
458439
end
@@ -465,23 +446,32 @@ local function check3rdByWords(uri, configs)
465446
return
466447
end
467448
for _, cfg in ipairs(configs) do
468-
if cfg.words then
469-
for _, word in ipairs(cfg.words) do
470-
await.delay()
471-
if wholeMatch(text, word) then
449+
if not cfg.words then
450+
goto CONTINUE
451+
end
452+
if hasAsked[cfg.name] then
453+
goto CONTINUE
454+
end
455+
local library = ('%s/library'):format(cfg.dirname)
456+
if util.arrayHas(config.get(uri, 'Lua.workspace.library'), library) then
457+
goto CONTINUE
458+
end
459+
for _, word in ipairs(cfg.words) do
460+
await.delay()
461+
if wholeMatch(text, word) then
462+
---@async
463+
await.call(function ()
472464
askFor3rd(uri, cfg)
473-
return
474-
end
465+
end)
466+
return
475467
end
476468
end
469+
::CONTINUE::
477470
end
478471
end, id)
479472
end
480473

481474
local function check3rdByFileName(uri, configs)
482-
if hasAsked then
483-
return
484-
end
485475
local path = ws.getRelativePath(uri)
486476
if not path then
487477
return
@@ -491,24 +481,29 @@ local function check3rdByFileName(uri, configs)
491481
await.call(function () ---@async
492482
await.sleep(0.1)
493483
for _, cfg in ipairs(configs) do
494-
if cfg.files then
495-
for _, filename in ipairs(cfg.files) do
496-
await.delay()
497-
if wholeMatch(path, filename) then
484+
if not cfg.files then
485+
goto CONTINUE
486+
end
487+
if hasAsked[cfg.name] then
488+
goto CONTINUE
489+
end
490+
for _, filename in ipairs(cfg.files) do
491+
await.delay()
492+
if wholeMatch(path, filename) then
493+
---@async
494+
await.call(function ()
498495
askFor3rd(uri, cfg)
499-
return
500-
end
496+
end)
497+
return
501498
end
502499
end
500+
::CONTINUE::
503501
end
504502
end, id)
505503
end
506504

507505
---@async
508506
local function check3rd(uri)
509-
if hasAsked then
510-
return
511-
end
512507
if ws.isIgnored(uri) then
513508
return
514509
end

0 commit comments

Comments
 (0)