Bump duplicated commands to the most recent in command prompt history
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
ba7c7eafff
commit
47238fe6cf
|
@ -97,9 +97,9 @@ end
|
||||||
-- @param id The data.history identifier
|
-- @param id The data.history identifier
|
||||||
-- @param command The command to add
|
-- @param command The command to add
|
||||||
local function history_add(id, command)
|
local function history_add(id, command)
|
||||||
if data.history[id] then
|
if data.history[id] and command ~= "" then
|
||||||
if command ~= ""
|
local index = util.table.hasitem(data.history[id].table, command)
|
||||||
and util.table.hasitem(data.history[id].table, command) == nil then
|
if index == nil then
|
||||||
table.insert(data.history[id].table, command)
|
table.insert(data.history[id].table, command)
|
||||||
|
|
||||||
-- Do not exceed our max_cmd
|
-- Do not exceed our max_cmd
|
||||||
|
@ -107,6 +107,11 @@ local function history_add(id, command)
|
||||||
table.remove(data.history[id].table, 1)
|
table.remove(data.history[id].table, 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
history_save(id)
|
||||||
|
else
|
||||||
|
-- Bump this command to the end of history
|
||||||
|
table.remove(data.history[id].table, index)
|
||||||
|
table.insert(data.history[id].table, command)
|
||||||
history_save(id)
|
history_save(id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue