@@ -202,9 +202,18 @@ M.preprocess = function(opts)
202202 end
203203 end
204204
205+ -- For custom command transformations (#1927)
206+ opts .fn_transform_cmd =
207+ load_config_section (" __resume_data.opts.fn_transform_cmd" , " function" , true )
208+
205209 -- did the caller request rg with glob support?
206210 -- manipulation needs to be done before the argv replacement
207- if opts .rg_glob then
211+ if opts .fn_transform_cmd then
212+ local query = argv (nil , opts .debug )
213+ local new_cmd , new_query = opts .fn_transform_cmd (query , opts .cmd :gsub (argvz , " " ), opts )
214+ opts .cmd = new_cmd or opts .cmd
215+ opts .cmd = opts .cmd :gsub (argvz , libuv .shellescape (new_query or query ))
216+ elseif opts .rg_glob then
208217 local query = argv (nil , opts .debug )
209218 local search_query , glob_args = M .glob_parse (query , opts )
210219 if glob_args then
@@ -219,14 +228,6 @@ M.preprocess = function(opts)
219228 end
220229 end
221230
222- -- For custom command transformations (#1927)
223- opts .fn_transform_cmd =
224- load_config_section (" __resume_data.opts.fn_transform_cmd" , " function" , true )
225- if opts .fn_transform_cmd then
226- local query = argv (nil , opts .debug )
227- opts .cmd = opts .fn_transform_cmd (query , opts .cmd :gsub (" {argv.*}" , " " ) ,opts )
228- end
229-
230231 -- nifty hack to avoid having to double escape quotations
231232 -- see my comment inside 'live_grep' initial_command code
232233 if opts .argv_expr then
0 commit comments