grep|tags_grep: save typed query as grep string when empty
This commit is contained in:
parent
d55db75d1a
commit
0219921e41
@ -137,6 +137,20 @@ M.grep = function(opts)
|
|||||||
contents = contents .. " 2>&1"
|
contents = contents .. " 2>&1"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- when using an empty string grep (as in 'grep_project') or
|
||||||
|
-- when switching from grep to live_grep using 'ctrl-g' users
|
||||||
|
-- may find it confusing why is the last typed query not
|
||||||
|
-- considered the last search so we find out if that's the
|
||||||
|
-- case and use the last typed prompt as the grep string
|
||||||
|
opts.fn_post_fzf = function(o, _)
|
||||||
|
local last_search, _ = get_last_search(o)
|
||||||
|
local last_query = config.__resume_data and config.__resume_data.last_query
|
||||||
|
if not last_search or #last_search==0
|
||||||
|
and (last_query and #last_query>0) then
|
||||||
|
set_last_search(opts, last_query)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
opts = core.set_fzf_field_index(opts)
|
opts = core.set_fzf_field_index(opts)
|
||||||
core.fzf_files(opts, contents)
|
core.fzf_files(opts, contents)
|
||||||
opts.search = nil
|
opts.search = nil
|
||||||
|
@ -102,6 +102,16 @@ local function tags(opts)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- see my comment in 'grep.lua:grep' what this is for
|
||||||
|
opts.fn_post_fzf = function(o, _)
|
||||||
|
local last_search, _ = M.get_last_search(o)
|
||||||
|
local last_query = config.__resume_data and config.__resume_data.last_query
|
||||||
|
if not last_search or #last_search==0
|
||||||
|
and (last_query and #last_query>0) then
|
||||||
|
M.set_last_search(opts, last_query)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- save the search query so the use can
|
-- save the search query so the use can
|
||||||
-- call the same search again
|
-- call the same search again
|
||||||
M.set_last_search(opts, opts.search, opts.no_esc)
|
M.set_last_search(opts, opts.search, opts.no_esc)
|
||||||
|
Loading…
Reference in New Issue
Block a user