awful.tag: Use sane tag index values (FS#1125)

Since commit d8a93dafa3, tags have an "index" property which decides about
the order in which they are displayed in the taglist. If a tag doesn't have this
property set, the next call to awful.tag.gettags() will fix this and "invent" an
index for this new tag.

However, if multiple tags didn't have an "index" property, gettags() would
assign all of them the same index. The following call to table.sort() would then
do random magic to these tags (remember: table.sort() is not a stable sorting
algorithm, so it is allowed to randomly swap around entries which have the same
sorting key).

Fix this by making sure that the new "index" properties are different from each
other.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2013-03-16 16:51:55 +01:00
parent 9d5e2a981a
commit 2b0398c59b
1 changed files with 1 additions and 0 deletions

View File

@ -256,6 +256,7 @@ function tag.gettags(s)
for _, t in ipairs(tags) do
if not tag.getproperty(t, "index") then
tag.setproperty(t, "index", (#tags - without_index + 1))
without_index = without_index - 1
end
end
end