tag: Fix index calculation.
The index was updated on an unordered table. As the elements order did not match the relative indices once they have been changed, further calls to set_index produced garbage. The default taglist didn't notice because it use screen.tags table index instead of the tag index. A debug using echo 'for _,t in ipairs(mouse.screen.tags) do print("INDEX:", _, t.index, t.name) end' | awesome-client Would have shown two or more elements with the same index. To debug issues related to tag indices, this bash script can be enabled: while true; do echo 'for _,t in ipairs(mouse.screen.tags) do assert( _==t.index) end' | awesome-client sleep 0.5 done
This commit is contained in:
parent
99489584cc
commit
bbfa6006f3
|
@ -74,6 +74,12 @@ function tag.object.set_index(self, idx)
|
|||
-- screen.tags cannot be used as it depend on index
|
||||
local tmp_tags = raw_tags(scr)
|
||||
|
||||
-- sort the tags by index
|
||||
table.sort(tmp_tags, function(a, b)
|
||||
local ia, ib = tag.getproperty(a, "index"), tag.getproperty(b, "index")
|
||||
return (ia or math.huge) < (ib or math.huge)
|
||||
end)
|
||||
|
||||
if (not idx) or (idx < 1) or (idx > #tmp_tags) then
|
||||
return
|
||||
end
|
||||
|
@ -97,13 +103,14 @@ function tag.object.set_index(self, idx)
|
|||
end
|
||||
|
||||
function tag.object.get_index(query_tag)
|
||||
-- Get an unordered list of tags
|
||||
local tags = raw_tags(query_tag.screen)
|
||||
|
||||
local idx = tag.getproperty(query_tag, "index")
|
||||
|
||||
if idx then return idx end
|
||||
|
||||
-- Get an unordered list of tags
|
||||
local tags = raw_tags(query_tag.screen)
|
||||
|
||||
-- Too bad, lets compute it
|
||||
for i, t in ipairs(tags) do
|
||||
if t == query_tag then
|
||||
|
|
Loading…
Reference in New Issue