Skip to content

Commit 3ba27b2

Browse files
committed
Redirect stdin to null. Fix off-by-one error for GrepArgs.
1 parent 7e00b8e commit 3ba27b2

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

‎autoload/grep.vim‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
" File: grep.vim
22
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com)
33
" Version: 2.1
4-
" Last Modified: March 4, 2018
4+
" Last Modified: March 11, 2018
55
"
66
" Plugin to integrate grep like utilities with Vim
77
" Supported ones are: grep, fgrep, egrep, agrep, findstr, ag, ack, ripgrep
@@ -232,7 +232,7 @@ endfunction
232232
function! grep#cmd_output_cb(qf_id, channel, msg)
233233
let job = ch_getjob(a:channel)
234234
if job_status(job) == 'fail'
235-
call warnMsg('Error: Job not found in grep command output callback')
235+
call s:warnMsg('Error: Job not found in grep command output callback')
236236
return
237237
endif
238238

@@ -262,7 +262,7 @@ endfunction
262262
function! grep#chan_close_cb(qf_id, channel)
263263
let job = ch_getjob(a:channel)
264264
if job_status(job) == 'fail'
265-
call warnMsg('Error: Job not found in grep channel close callback')
265+
call s:warnMsg('Error: Job not found in grep channel close callback')
266266
return
267267
endif
268268
let emsg = '[Search command exited with status ' . job_info(job).exitval . ']'
@@ -325,7 +325,8 @@ function! s:runGrepCmdAsync(cmd, pattern, action)
325325
let s:grep_cmd_job = job_start(cmd_list,
326326
\ {'callback' : function('grep#cmd_output_cb', [qf_id]),
327327
\ 'close_cb' : function('grep#chan_close_cb', [qf_id]),
328-
\ 'exit_cb' : function('grep#cmd_exit_cb', [qf_id])})
328+
\ 'exit_cb' : function('grep#cmd_exit_cb', [qf_id]),
329+
\ 'in_io' : 'null'})
329330

330331
if job_status(s:grep_cmd_job) == 'fail'
331332
let s:grep_cmd_job = 0
@@ -478,13 +479,6 @@ function! s:formFullCmd(cmd_name, useropts, pattern, filenames)
478479
\ a:pattern . ' ' . a:filenames . ' ' .
479480
\ s:cmdTable[a:cmd_name].nulldev
480481

481-
" Some commands like ripgrep try to read from stdin. This hangs the
482-
" command as Vim controls stdin. To avoid this problem, redirect stdin to
483-
" the NULL device for commands that search recursively by default.
484-
if s:recursive_search_cmd(a:cmd_name)
485-
let fullcmd = fullcmd . ' < ' . g:Grep_Null_Device
486-
endif
487-
488482
return fullcmd
489483
endfunction
490484

@@ -517,7 +511,7 @@ function! s:getListOfArgFiles()
517511

518512
let arg_cnt = argc()
519513
if arg_cnt != 0
520-
for i in range(0, arg_cnt)
514+
for i in range(0, arg_cnt - 1)
521515
let filenames = filenames . ' ' . argv(i)
522516
endfor
523517
endif

0 commit comments

Comments
 (0)