From 016b76e7bbc041145f2cd3642467c732766fc9ff Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Wed, 20 Oct 2010 17:30:48 +0200 Subject: [PATCH] awful.tag: do not update history when identical tags Signed-off-by: Julien Danjou --- lib/awful/tag.lua.in | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/awful/tag.lua.in b/lib/awful/tag.lua.in index 0ade9850..e918de08 100644 --- a/lib/awful/tag.lua.in +++ b/lib/awful/tag.lua.in @@ -162,20 +162,38 @@ end -- @param obj Screen object. function history.update(obj) local s = obj.index + local curtags = selectedlist(s) -- create history table if not data.history[s] then data.history[s] = {} - -- limit history - elseif #data.history[s] >= history.limit then - for i = history.limit, #data.history[s] do - data.history[s][i] = nil + else + if data.history[s].current then + -- Check that the list is not identical + local identical = true + for idx, tag in ipairs(data.history[s].current) do + if curtags[idx] ~= tag then + identical = false + break + end + end + + -- Do not update history the table are identical + if identical then return end + end + + -- Limit history + if #data.history[s] >= history.limit then + for i = history.limit, #data.history[s] do + data.history[s][i] = nil + end end end + -- store previously selected tags in the history table table.insert(data.history[s], 1, data.history[s].current) data.history[s].previous = data.history[s][1] -- store currently selected tags - data.history[s].current = setmetatable(selectedlist(s), { __mode = 'v' }) + data.history[s].current = setmetatable(curtags, { __mode = 'v' }) end --- Revert tag history.