From 180e70f6d682391a8ffae7ec1300f740d1981cfd Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 28 Aug 2016 19:02:39 -0400 Subject: [PATCH] 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. --- lib/awful/tag.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/awful/tag.lua b/lib/awful/tag.lua index 063d0440d..5a4e18106 100644 --- a/lib/awful/tag.lua +++ b/lib/awful/tag.lua @@ -308,8 +308,10 @@ function tag.object.delete(self, fallback_tag, force) tag.setproperty(tags[i], "index", i-1) end - -- If no tags are visible, try and view one. - if target_scr.selected_tag == nil and ntags > 0 then + -- If no tags are visible (and we did not delete the lasttag), try and + -- 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) if target_scr.selected_tag == nil then local other_tag = tags[tags[1] == self and 2 or 1]