tag:delete(): Allow deletion of the last tag

When a tag is deleted, this code tries to select some other tag. If the tag
which is to delete is the last tag of a screen, this code failed and indexed a
nil value. Fix this with a simple "if".

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-04-17 15:42:15 +02:00 committed by Uli Schlachter
parent 2485d334cf
commit 9b44e9a011
1 changed files with 4 additions and 1 deletions

View File

@ -305,7 +305,10 @@ function tag.object.delete(self, fallback_tag)
if target_scr.selected_tag == nil and ntags > 0 then
tag.history.restore(nil, 1)
if target_scr.selected_tag == nil then
tags[tags[1] == self and 2 or 1].selected = true
local other_tag = tags[tags[1] == self and 2 or 1]
if other_tag then
other_tag.selected = true
end
end
end