From b8c172a2dcd9e58c624cb4a7ad583debaa7b3b0a Mon Sep 17 00:00:00 2001 From: Massimiliano Brocchini Date: Sat, 22 Feb 2014 12:24:59 +0100 Subject: [PATCH] prompt: search in prompt history using exact string match The default value for the second argument to :find() is 1, so nothing is changed here. The third arguments disables pattern matching and instead gets us literal interpretation of strings. This means that pattern characters like e.g. [, ] and . don't get interpreted. Signed-off-by: Massimiliano Brocchini Signed-off-by: Uli Schlachter --- lib/awful/prompt.lua.in | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/awful/prompt.lua.in b/lib/awful/prompt.lua.in index 14c0ca8c..26130702 100644 --- a/lib/awful/prompt.lua.in +++ b/lib/awful/prompt.lua.in @@ -280,7 +280,7 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa elseif key == "r" then search_term = search_term or command:sub(1, cur_pos - 1) for i,v in (function(a,i) return itera(-1,a,i) end), data.history[history_path].table, history_index do - if v:find(search_term) ~= nil then + if v:find(search_term,1,true) ~= nil then command=v history_index=i cur_pos=#command+1 @@ -290,7 +290,7 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa elseif key == "s" then search_term = search_term or command:sub(1, cur_pos - 1) for i,v in (function(a,i) return itera(1,a,i) end), data.history[history_path].table, history_index do - if v:find(search_term) ~= nil then + if v:find(search_term,1,true) ~= nil then command=v history_index=i cur_pos=#command+1 @@ -314,7 +314,7 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa elseif key == "Up" then search_term = command:sub(1, cur_pos - 1) or "" for i,v in (function(a,i) return itera(-1,a,i) end), data.history[history_path].table, history_index do - if v:find('^'..search_term) ~= nil then + if v:find(search_term,1,true) == 1 then command=v history_index=i break @@ -323,7 +323,7 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa elseif key == "Down" then search_term = command:sub(1, cur_pos - 1) or "" for i,v in (function(a,i) return itera(1,a,i) end), data.history[history_path].table, history_index do - if v:find('^'..search_term) ~= nil then + if v:find(search_term,1,true) == 1 then command=v history_index=i break