Fixing minor bug relating to TreeView's cache. (#1136)

Reviewed by Guldo; should fix things, merging.
This commit is contained in:
Adam 2022-10-04 18:26:33 -04:00 committed by GitHub
parent 630ab0ab92
commit 1580d923d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 15 deletions

View File

@ -50,20 +50,6 @@ function TreeView:new()
self.item_icon_width = 0 self.item_icon_width = 0
self.item_text_spacing = 0 self.item_text_spacing = 0
self:add_core_hooks()
end
function TreeView:add_core_hooks()
-- When a file or directory is deleted we delete the corresponding cache entry
-- because if the entry is recreated we may use wrong information from cache.
local on_delete = core.on_dirmonitor_delete
core.on_dirmonitor_delete = function(dir, filepath)
local cache = self.cache[dir.name]
if cache then cache[filepath] = nil end
on_delete(dir, filepath)
end
end end
@ -86,7 +72,7 @@ function TreeView:get_cached(dir, item, dirname)
-- used only to identify the entry into the cache. -- used only to identify the entry into the cache.
local cache_name = item.filename .. (item.topdir and ":" or "") local cache_name = item.filename .. (item.topdir and ":" or "")
local t = dir_cache[cache_name] local t = dir_cache[cache_name]
if not t then if not t or t.type ~= item.type then
t = {} t = {}
local basename = common.basename(item.filename) local basename = common.basename(item.filename)
if item.topdir then if item.topdir then