tag: Fix off by one when deleting.

If a tag has been deleted, then the number of tags is decremented,
the code still used the old count.
This commit is contained in:
Emmanuel Lepage Vallee 2016-08-28 19:02:39 -04:00
parent 2af0553b67
commit 180e70f6d6
1 changed files with 4 additions and 2 deletions

View File

@ -308,8 +308,10 @@ function tag.object.delete(self, fallback_tag, force)
tag.setproperty(tags[i], "index", i-1) tag.setproperty(tags[i], "index", i-1)
end end
-- If no tags are visible, try and view one. -- If no tags are visible (and we did not delete the lasttag), try and
if target_scr.selected_tag == nil and ntags > 0 then -- view one. The > 1 is because ntags is no longer synchronized with the
-- current count.
if target_scr.selected_tag == nil and ntags > 1 then
tag.history.restore(nil, 1) tag.history.restore(nil, 1)
if target_scr.selected_tag == nil then if target_scr.selected_tag == nil then
local other_tag = tags[tags[1] == self and 2 or 1] local other_tag = tags[tags[1] == self and 2 or 1]