From 757ee2ca6248f445bd6d657633892d28a0ff8034 Mon Sep 17 00:00:00 2001 From: Bart Trojanowski Date: Tue, 11 Dec 2007 10:40:11 -0500 Subject: [PATCH] fixed a few bugs with action/program history --- core/history.lua | 23 +++++++++++++++++++++++ core/wmii.lua | 17 ++++++++++------- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/core/history.lua b/core/history.lua index e4d404d..e6cc666 100644 --- a/core/history.lua +++ b/core/history.lua @@ -78,4 +78,27 @@ function history:walk_reverse () end end +function history:walk_reverse_unique () + local s = self + + local iterator = s:walk_reverse() + if not iterator then + return function () + return nil + end + end + + local seen = {} + return function () + local v = iterator() + while v do + if not seen[v] then + seen[v] = 1 + return v + end + v = iterator() + end + end +end + diff --git a/core/wmii.lua b/core/wmii.lua index 4d4a879..e71c39c 100644 --- a/core/wmii.lua +++ b/core/wmii.lua @@ -376,7 +376,7 @@ function prog_menu () dmenu[#dmenu+1] = outfile local hstt = { } - for n in prog_hist:walk_reverse() do + for n in prog_hist:walk_reverse_unique() do hstt[#hstt+1] = "echo '" .. n .. "' ; " end @@ -625,14 +625,17 @@ function ke_handle_action() local n for n in action_hist:walk_reverse() do - actions[#actions+1] = n - seen[n] = 1 + if not seen[n] then + actions[#actions+1] = n + seen[n] = 1 + end end - local i,v - for i,v in pairs(action_handlers) do - if not seen[i] then - actions[#actions+1] = i + local v + for n,v in pairs(action_handlers) do + if not seen[n] then + actions[#actions+1] = n + seen[n] = 1 end end -- 2.11.4.GIT