Make sure "Clear history of deleted files" actually persists. (#6557)

* Make sure "Clear history of deleted files" actually persists.

The current code was only clearing the live table, it was forgotten after a restart.
reviewable/pr6560/r1
NiLuJe 4 years ago committed by GitHub
parent ae19cafe84
commit 9abd92044a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -200,7 +200,7 @@ function ReadHistory:clearMissing()
assert(self ~= nil)
for i = #self.hist, 1, -1 do
if self.hist[i].file == nil or lfs.attributes(self.hist[i].file, "mode") ~= "file" then
table.remove(self.hist, i)
self:removeItem(self.hist[i], i)
end
end
self:ensureLastFile()
@ -237,11 +237,11 @@ function ReadHistory:updateItemByPath(old_path, new_path)
self:ensureLastFile()
end
function ReadHistory:removeItem(item)
function ReadHistory:removeItem(item, idx)
assert(self ~= nil)
table.remove(self.hist, item.index)
table.remove(self.hist, item.index or idx)
os.remove(DocSettings:getHistoryPath(item.file))
self:_indexing(item.index)
self:_indexing(item.index or idx)
self:_flush()
self:ensureLastFile()
end

@ -37,13 +37,13 @@ describe("ReadHistory module", function()
end
local function assert_item_is(h, i, name, fileRemoved)
assert.is.same(h.hist[i].text, name)
assert.is.same(h.hist[i].index, i)
assert.is.same(h.hist[i].file, joinPath(realpath(test_data_dir()), name))
assert.is.same(name, h.hist[i].text)
assert.is.same(i, h.hist[i].index)
assert.is.same(joinPath(realpath(test_data_dir()), name), h.hist[i].file)
if fileRemoved then
assert.is_nil(realpath(test_file(name)))
else
assert.is.same(h.hist[i].file, realpath(test_file(name)))
assert.is.same(realpath(test_file(name)), h.hist[i].file)
end
end

Loading…
Cancel
Save