From 2e4fdbb40d3fa14f85b13d5fd66a0f64b2f936a2 Mon Sep 17 00:00:00 2001 From: Damien Leone Date: Mon, 11 Aug 2008 20:39:03 +0200 Subject: [PATCH] awful: fix empty command adding Signed-off-by: Julien Danjou --- lib/awful.lua.in | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/awful.lua.in b/lib/awful.lua.in index 999f8652..7ce832f8 100644 --- a/lib/awful.lua.in +++ b/lib/awful.lua.in @@ -779,7 +779,7 @@ end --- Set path for history file -- @param path The history file path, set "on" to enable history in the default file (~/.awesome_history) --- @param max_size Optional parameter: set the max entries number in the history file, 50 by default +-- @param max_cmd Optional parameter: set the max entries number in the history file, 50 by default function prompt.history.set(path, max_cmd) if path then prompt.history.data.path = path @@ -809,18 +809,19 @@ end --- Add an entry to the history file -- @param command The command to add local function prompt_history_add(command) - if prompt.history.data.path - and command - and command ~= prompt.history.data.table[#prompt.history.data.table] then - table.insert(prompt.history.data.table, command) - - -- Do not exceed our max_cmd - if #prompt.history.data.table > prompt.history.data.max then - table.remove(prompt.history.data.table, 1) - end + if prompt.history.data.path then + if command ~= "" + and command ~= prompt.history.data.table[#prompt.history.data.table] then + table.insert(prompt.history.data.table, command) + + -- Do not exceed our max_cmd + if #prompt.history.data.table > prompt.history.data.max then + table.remove(prompt.history.data.table, 1) + end - -- Save table content in file, not very optimized atm... - prompt_history_save() + -- Save table content in file, not very optimized atm... + prompt_history_save() + end prompt.history.data.index = #prompt.history.data.table + 1 end @@ -1055,6 +1056,8 @@ function prompt.run(args, textbox, exe_callback, completion_callback) command = prompt.history.data.table[prompt.history.data.index] cur_pos = #command + 2 elseif prompt.history.data.index == #prompt.history.data.table then + prompt.history.data.index = prompt.history.data.index + 1 + command = "" cur_pos = 1 end -- 2.11.4.GIT