Skip to content

Commit a6798e6

Browse files
committed
fix #1796
1 parent 7dc490d commit a6798e6

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* `FIX` [#1737]
1616
* `FIX` [#1751]
1717
* `FIX` [#1767]
18+
* `FIX` [#1796]
1819
* `FIX` [#1805]
1920
* `FIX` [#1808]
2021
* `FIX` [#1811]
@@ -25,6 +26,7 @@
2526
[#1737]: https://github.com/sumneko/lua-language-server/issues/1737
2627
[#1751]: https://github.com/sumneko/lua-language-server/issues/1751
2728
[#1767]: https://github.com/sumneko/lua-language-server/issues/1767
29+
[#1796]: https://github.com/sumneko/lua-language-server/issues/1796
2830
[#1805]: https://github.com/sumneko/lua-language-server/issues/1805
2931
[#1808]: https://github.com/sumneko/lua-language-server/issues/1808
3032
[#1811]: https://github.com/sumneko/lua-language-server/issues/1811

script/library.lua

+14-12
Original file line numberDiff line numberDiff line change
@@ -188,10 +188,14 @@ local function compileSingleMetaDoc(uri, script, metaLang, status)
188188
if not suc then
189189
log.debug('MiddleScript:\n', middleScript)
190190
end
191+
local text = table.concat(compileBuf)
191192
if disable and status == 'default' then
192-
return nil
193+
return text, false
194+
end
195+
if status == 'disable' then
196+
return text, false
193197
end
194-
return table.concat(compileBuf)
198+
return text, true
195199
end
196200

197201
local function loadMetaLocale(langID, result)
@@ -222,11 +226,8 @@ local function initBuiltIn(uri)
222226
loadMetaLocale(langID, metaLang)
223227
end
224228

225-
if scp:get('metaPath') == metaPath:string() then
226-
log.debug('Has meta path, skip:', metaPath:string())
227-
return
228-
end
229-
scp:set('metaPath', metaPath:string())
229+
local metaPaths = {}
230+
scp:set('metaPaths', metaPaths)
230231
local suc = xpcall(function ()
231232
if not fs.exists(metaPath) then
232233
fs.create_directories(metaPath)
@@ -241,13 +242,10 @@ local function initBuiltIn(uri)
241242
for libName, status in pairs(define.BuiltIn) do
242243
status = config.get(uri, 'Lua.runtime.builtin')[libName] or status
243244
log.debug('Builtin status:', libName, status)
244-
if status == 'disable' then
245-
goto CONTINUE
246-
end
247245

248246
---@type fs.path
249247
local libPath = templateDir / (libName .. '.lua')
250-
local metaDoc = compileSingleMetaDoc(uri, fsu.loadFile(libPath), metaLang, status)
248+
local metaDoc, include = compileSingleMetaDoc(uri, fsu.loadFile(libPath), metaLang, status)
251249
if metaDoc then
252250
metaDoc = encoder.encode(encoding, metaDoc, 'auto')
253251

@@ -258,13 +256,17 @@ local function initBuiltIn(uri)
258256

259257
local ok, err = out:saveFile(outputLibName, metaDoc)
260258
if not ok then
261-
log.debug("Save Meta File:", err)
259+
log.debug("Save Meta File Failed:", err)
262260
goto CONTINUE
263261
end
264262

265263
local outputPath = metaPath / outputLibName
266264
m.metaPaths[outputPath:string()] = true
267265
log.debug('Meta path:', outputPath:string())
266+
267+
if include then
268+
metaPaths[#metaPaths+1] = outputPath:string()
269+
end
268270
end
269271
::CONTINUE::
270272
end

script/workspace/workspace.lua

+6-3
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,12 @@ function m.getLibraryMatchers(scp)
204204
librarys[m.normalize(path)] = true
205205
end
206206
end
207-
log.debug('meta path:', scp:get 'metaPath')
208-
if scp:get 'metaPath' then
209-
librarys[m.normalize(scp:get 'metaPath')] = true
207+
local metaPaths = scp:get 'metaPaths'
208+
log.debug('meta path:', inspect(metaPaths))
209+
if metaPaths then
210+
for _, metaPath in ipairs(metaPaths) do
211+
librarys[m.normalize(metaPath)] = true
212+
end
210213
end
211214

212215
local matchers = {}

0 commit comments

Comments
 (0)