Skip to content

Commit

Permalink
Rename Grep_Use_Async to Grep_Run_Async. Update the doc.
Browse files Browse the repository at this point in the history
  • Loading branch information
yegappan committed Feb 5, 2018
1 parent 6fc6646 commit 47c80de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
16 changes: 9 additions & 7 deletions autoload/grep.vim
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ endif

" Run the grep commands asynchronously and update the quickfix list with the
" results in the background
if !exists('Grep_Use_Async')
if !exists('Grep_Run_Async')
" Check whether we can run the grep command asynchronously.
if v:version >= 800
let Grep_Use_Async = 1
let Grep_Run_Async = 1
" Check whether we can use the quickfix identifier to add the grep
" output to a specific quickfix list
if has('patch-8.0.1023')
Expand All @@ -133,7 +133,7 @@ if !exists('Grep_Use_Async')
let s:Grep_Use_QfID = 0
endif
else
let Grep_Use_Async = 0
let Grep_Run_Async = 0
endif
endif

Expand Down Expand Up @@ -166,8 +166,9 @@ function! grep#cmd_output_cb(qf_id, channel, msg)
call WarnMsg('Error: Job not found in grep command output callback')
return
endif

" Check whether the quickfix list is still present
if s:Grep_Use_QfID
" Check whether the quickfix list is still present
let l = getqflist({'id' : a:qf_id})
if !has_key(l, 'id') || l.id == 0
" Quickfix list is not present. Stop the search.
Expand Down Expand Up @@ -196,8 +197,9 @@ function! grep#chan_close_cb(qf_id, channel)
return
endif
let emsg = '[Search command exited with status ' . job_info(job).exitval . ']'

" Check whether the quickfix list is still present
if s:Grep_Use_QfID
" Check whether the quickfix list is still present
let l = getqflist({'id' : a:qf_id})
if has_key(l, 'id') && l.id == a:qf_id
call setqflist([], 'a', {'id' : a:qf_id,
Expand Down Expand Up @@ -283,7 +285,7 @@ function! grep#runGrepCmd(cmd, pattern, action)
let s:grep_tempfile = fnamemodify(tempname(), ':h') . '\mygrep.cmd'
call writefile(['@echo off', a:cmd], s:grep_tempfile)

if g:Grep_Use_Async
if g:Grep_Run_Async
call grep#runGrepCmdAsync(s:grep_tempfile, a:pattern, a:action)
return
endif
Expand All @@ -294,7 +296,7 @@ function! grep#runGrepCmd(cmd, pattern, action)
call delete(s:grep_tempfile)
endif
else
if g:Grep_Use_Async
if g:Grep_Run_Async
return grep#runGrepCmdAsync(a:cmd, a:pattern, a:action)
endif
let cmd_output = system(a:cmd)
Expand Down
5 changes: 5 additions & 0 deletions doc/grep.txt
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,11 @@ empty string. You can change this using the let command:

:let Grep_Shell_Escape_Char = "'"

The 'Grep_Run_Async' variable specifies whether the grep commands are run
synchronously or asynchronously. Depending on the Vim version, this variable
is set automatically. If you want to force Vim to run the grep commands
synchronously, then you can set the 'Grep_Run_Async' variable to 1.

==============================================================================
*grep-license*
5. License~
Expand Down

0 comments on commit 47c80de

Please sign in to comment.