Skip to content

Commit

Permalink
filewatch before scanning workspace
Browse files Browse the repository at this point in the history
fix #1640
  • Loading branch information
sumneko committed Oct 22, 2022
1 parent 416b7a8 commit 137d40a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ server will generate `doc.json` and `doc.md` in `LOGPATH`.
* `FIX` [#1606]
* `FIX` [#1608]
* `FIX` [#1637]
* `FIX` [#1640]
* `FIX` [#1642]

[#1177]: https://github.com/sumneko/lua-language-server/issues/1177
Expand All @@ -60,6 +61,7 @@ server will generate `doc.json` and `doc.md` in `LOGPATH`.
[#1608]: https://github.com/sumneko/lua-language-server/issues/1608
[#1626]: https://github.com/sumneko/lua-language-server/issues/1626
[#1637]: https://github.com/sumneko/lua-language-server/issues/1637
[#1640]: https://github.com/sumneko/lua-language-server/issues/1640
[#1641]: https://github.com/sumneko/lua-language-server/issues/1641
[#1642]: https://github.com/sumneko/lua-language-server/issues/1642

Expand Down
4 changes: 2 additions & 2 deletions script/files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function m.addRef(uri)
return nil
end
file._ref = (file._ref or 0) + 1
log.debug('add ref', uri)
log.debug('add ref', uri, file._ref)
return function ()
m.delRef(uri)
end
Expand All @@ -432,7 +432,7 @@ function m.delRef(uri)
return
end
file._ref = (file._ref or 0) - 1
log.debug('del ref', uri)
log.debug('del ref', uri, file._ref)
if file._ref <= 0 and not m.isOpen(uri) then
m.remove(uri)
end
Expand Down
4 changes: 2 additions & 2 deletions script/workspace/workspace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ function m.awaitPreload(scp)

if scp.uri and not scp:get('bad root') then
log.info('Scan files at:', scp:getName())
scp:gc(fw.watch(m.normalize(furi.decode(scp.uri))))
local count = 0
---@async
native:scan(furi.decode(scp.uri), function (path)
Expand All @@ -320,12 +321,12 @@ function m.awaitPreload(scp)
client.showMessage('Warning', lang.script('WORKSPACE_SCAN_TOO_MUCH', count, furi.decode(scp.uri)))
end
end)
scp:gc(fw.watch(m.normalize(furi.decode(scp.uri))))
end

for _, libMatcher in ipairs(librarys) do
log.info('Scan library at:', libMatcher.uri)
local count = 0
scp:gc(fw.watch(furi.decode(libMatcher.uri)))
scp:addLink(libMatcher.uri)
---@async
libMatcher.matcher:scan(furi.decode(libMatcher.uri), function (path)
Expand All @@ -338,7 +339,6 @@ function m.awaitPreload(scp)
client.showMessage('Warning', lang.script('WORKSPACE_SCAN_TOO_MUCH', count, furi.decode(libMatcher.uri)))
end
end)
scp:gc(fw.watch(furi.decode(libMatcher.uri)))
end

-- must wait for other scopes to add library
Expand Down

0 comments on commit 137d40a

Please sign in to comment.