Skip to content

Commit 137d40a

Browse files
committed
filewatch before scanning workspace
fix #1640
1 parent 416b7a8 commit 137d40a

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ server will generate `doc.json` and `doc.md` in `LOGPATH`.
4444
* `FIX` [#1606]
4545
* `FIX` [#1608]
4646
* `FIX` [#1637]
47+
* `FIX` [#1640]
4748
* `FIX` [#1642]
4849

4950
[#1177]: https://github.com/sumneko/lua-language-server/issues/1177
@@ -60,6 +61,7 @@ server will generate `doc.json` and `doc.md` in `LOGPATH`.
6061
[#1608]: https://github.com/sumneko/lua-language-server/issues/1608
6162
[#1626]: https://github.com/sumneko/lua-language-server/issues/1626
6263
[#1637]: https://github.com/sumneko/lua-language-server/issues/1637
64+
[#1640]: https://github.com/sumneko/lua-language-server/issues/1640
6365
[#1641]: https://github.com/sumneko/lua-language-server/issues/1641
6466
[#1642]: https://github.com/sumneko/lua-language-server/issues/1642
6567

script/files.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ function m.addRef(uri)
420420
return nil
421421
end
422422
file._ref = (file._ref or 0) + 1
423-
log.debug('add ref', uri)
423+
log.debug('add ref', uri, file._ref)
424424
return function ()
425425
m.delRef(uri)
426426
end
@@ -432,7 +432,7 @@ function m.delRef(uri)
432432
return
433433
end
434434
file._ref = (file._ref or 0) - 1
435-
log.debug('del ref', uri)
435+
log.debug('del ref', uri, file._ref)
436436
if file._ref <= 0 and not m.isOpen(uri) then
437437
m.remove(uri)
438438
end

script/workspace/workspace.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ function m.awaitPreload(scp)
308308

309309
if scp.uri and not scp:get('bad root') then
310310
log.info('Scan files at:', scp:getName())
311+
scp:gc(fw.watch(m.normalize(furi.decode(scp.uri))))
311312
local count = 0
312313
---@async
313314
native:scan(furi.decode(scp.uri), function (path)
@@ -320,12 +321,12 @@ function m.awaitPreload(scp)
320321
client.showMessage('Warning', lang.script('WORKSPACE_SCAN_TOO_MUCH', count, furi.decode(scp.uri)))
321322
end
322323
end)
323-
scp:gc(fw.watch(m.normalize(furi.decode(scp.uri))))
324324
end
325325

326326
for _, libMatcher in ipairs(librarys) do
327327
log.info('Scan library at:', libMatcher.uri)
328328
local count = 0
329+
scp:gc(fw.watch(furi.decode(libMatcher.uri)))
329330
scp:addLink(libMatcher.uri)
330331
---@async
331332
libMatcher.matcher:scan(furi.decode(libMatcher.uri), function (path)
@@ -338,7 +339,6 @@ function m.awaitPreload(scp)
338339
client.showMessage('Warning', lang.script('WORKSPACE_SCAN_TOO_MUCH', count, furi.decode(libMatcher.uri)))
339340
end
340341
end)
341-
scp:gc(fw.watch(furi.decode(libMatcher.uri)))
342342
end
343343

344344
-- must wait for other scopes to add library

0 commit comments

Comments
 (0)