@@ -379,6 +379,12 @@ function! s:parseArgs(args)
379379 return [cmdopt, pattern, filepattern]
380380endfunction
381381
382+ " recursive_search_cmd
383+ " Returns TRUE if a command recursively searches by default.
384+ function ! s: recursive_search_cmd (cmd_name)
385+ return a: cmd_name == ' ag' || a: cmd_name == ' rg' || a: cmd_name == ' ack'
386+ endfunction
387+
382388" formFullCmd()
383389" Generate the full command to run based on the user supplied command name,
384390" options, pattern and file names.
@@ -455,8 +461,10 @@ function! s:formFullCmd(cmd_name, useropts, pattern, filenames)
455461
456462 " Some commands like ripgrep try to read from stdin. This hangs the
457463 " command as Vim controls stdin. To avoid this problem, redirect stdin to
458- " the NULL device.
459- let fullcmd = fullcmd . ' < ' . g: Grep_Null_Device
464+ " the NULL device for commands that search recursively by default.
465+ if s: recursive_search_cmd (a: cmd_name )
466+ let fullcmd = fullcmd . ' < ' . g: Grep_Null_Device
467+ endif
460468
461469 return fullcmd
462470endfunction
@@ -648,12 +656,6 @@ function! grep#runGrepSpecial(cmd_name, which, action, ...)
648656 call s: runGrepCmd (cmd, pattern, a: action )
649657endfunction
650658
651- " recursive_search_cmd
652- " Returns TRUE if a command recursively searches by default.
653- function ! s: recursive_search_cmd (cmd_name)
654- return a: cmd_name == ' ag' || a: cmd_name == ' rg' || a: cmd_name == ' ack'
655- endfunction
656-
657659" grep#runGrep()
658660" Run the specified grep command
659661function ! grep#runGrep (cmd_name, grep_cmd, action, ... )
0 commit comments