Skip to content

Commit c6f8ffc

Browse files
cache: fix some bugs with previous directory handling
1 parent 6a308c0 commit c6f8ffc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

modules/parsers/cache.lua

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ local pending_parses = {}
2525
---@param directories? string[]
2626
local function clear_cache(directories)
2727
if directories then
28-
msg.debug('clearing cache', table.concat(directories, '\n'))
28+
msg.debug('clearing cache for', #directories, 'directorie(s)')
2929
for _, dir in ipairs(directories) do
3030
if cache[dir] then
31+
msg.trace('clearing cache for', dir)
3132
cache[dir].timeout:kill()
3233
cache[dir] = nil
3334
end
@@ -48,6 +49,7 @@ function cacheParser:can_parse(directory, parse_state)
4849
-- allows the cache to be forcibly used or bypassed with the
4950
-- cache/use parse property.
5051
if parse_state.properties.cache and parse_state.properties.cache.use ~= nil then
52+
if parse_state.source == 'browser' then prev_directory = directory end
5153
return parse_state.properties.cache.use
5254
end
5355

@@ -58,8 +60,8 @@ function cacheParser:can_parse(directory, parse_state)
5860
-- clear the cache if reloading the current directory in the browser
5961
-- this means that fb.rescan() should maintain expected behaviour
6062
if parse_state.source == 'browser' then
61-
prev_directory = directory
6263
if prev_directory == directory then clear_cache({directory}) end
64+
prev_directory = directory
6365
end
6466

6567
return true

0 commit comments

Comments
 (0)