@@ -430,19 +430,20 @@ end
430430
431431--- @param opts table
432432--- @param query string
433+ --- @param cmd string
433434--- @return string
434- M .expand_query = function (opts , query )
435+ M .expand_query = function (opts , query , cmd )
435436 -- live_grep replace pattern with last argument
436437 local argvz = " <query>"
437- if opts . cmd :match (argvz ) then
438+ if cmd :match (argvz ) then
438439 -- The NEQ condition on Windows turned out to be a real pain in the butt
439440 -- so I decided to move the empty query test into our cmd proxy wrapper
440441 -- For obvious reasons this cannot work with `live_grep_native` and thus
441442 -- the NEQ condition remains for the "native" version
442443 if not opts .exec_empty_query and query == " " then
443444 -- query is always be the last argument
444- opts . cmd = utils .shell_nop ()
445- return opts . cmd
445+ cmd = utils .shell_nop ()
446+ return cmd
446447 end
447448
448449 -- For custom command transformations (#1927)
@@ -451,8 +452,8 @@ M.expand_query = function(opts, query)
451452 -- did the caller request rg with glob support?
452453 -- manipulation needs to be done before the argv replacement
453454 if opts .fn_transform_cmd then
454- local new_cmd , new_query = opts .fn_transform_cmd (query , opts . cmd :gsub (argvz , " " ), opts )
455- opts . cmd = new_cmd or opts . cmd
455+ local new_cmd , new_query = opts .fn_transform_cmd (query , cmd :gsub (argvz , " " ), opts )
456+ cmd = new_cmd or cmd
456457 query = new_query or query
457458 elseif opts .rg_glob then
458459 local search_query , glob_args = M .glob_parse (query , opts )
@@ -462,15 +463,15 @@ M.expand_query = function(opts, query)
462463 -- reset argvz so it doesn't get replaced again below
463464 -- insert glob args before `-- {argvz}` or `-e {argvz}` repositioned
464465 -- at the end of the command preceding the search query (#781, #794)
465- opts . cmd = M .rg_insert_args (opts . cmd , glob_args , argvz )
466+ cmd = M .rg_insert_args (cmd , glob_args , argvz )
466467 query = search_query
467468 end
468469 end
469470 -- nifty hack to avoid having to double escape quotations
470471 -- see my comment inside 'live_grep' initial_command code
471- opts . cmd = opts . cmd :gsub (argvz , libuv .shellescape (query ))
472+ cmd = cmd :gsub (argvz , libuv .shellescape (query ))
472473 end
473- return opts . cmd
474+ return cmd
474475end
475476
476477M .preprocess = function (opts )
0 commit comments