no duplicate entries in prompt history

Signed-off-by: Massimiliano Brocchini <massimiliano.brocchini@gmail.com>
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Massimiliano Brocchini 2011-10-22 15:56:30 +02:00 committed by Uli Schlachter
parent 092813cd63
commit bf8e6418f5
1 changed files with 7 additions and 5 deletions

View File

@ -43,10 +43,12 @@ local function history_check_load(id, max)
-- Read history file
if f then
for line in f:lines() do
table.insert(data.history[id].table, line)
if #data.history[id].table >= data.history[id].max then
break
end
if util.table.hasitem(data.history[id].table, line) == nil then
table.insert(data.history[id].table, line)
if #data.history[id].table >= data.history[id].max then
break
end
end
end
f:close()
end
@ -90,7 +92,7 @@ end
local function history_add(id, command)
if data.history[id] then
if command ~= ""
and command ~= data.history[id].table[#data.history[id].table] then
and util.table.hasitem(data.history[id].table, command) == nil then
table.insert(data.history[id].table, command)
-- Do not exceed our max_cmd