-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redirect stdin to null for the search command
- Loading branch information
Showing
2 changed files
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
" File: grep.vim | ||
" Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) | ||
" Version: 2.0 | ||
" Last Modified: Feb 20, 2018 | ||
" Last Modified: Feb 25, 2018 | ||
" | ||
" Plugin to integrate grep like utilities with Vim | ||
|
||
|
@@ -453,6 +453,11 @@ function! s:formFullCmd(cmd_name, useropts, pattern, filenames) | |
\ a:pattern . ' ' . a:filenames . ' ' . | ||
\ cmdmap[a:cmd_name].nulldev | ||
|
||
" Some commands like ripgrep try to read from stdin. This hangs the | ||
" command as Vim controls stdin. To avoid this problem, redirect stdin to | ||
" the NULL device. | ||
let fullcmd = fullcmd . ' < ' . g:Grep_Null_Device | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yegappan
via email
Author
Owner
|
||
|
||
return fullcmd | ||
endfunction | ||
|
||
|
@@ -643,6 +648,12 @@ function! grep#runGrepSpecial(cmd_name, which, action, ...) | |
call s:runGrepCmd(cmd, pattern, a:action) | ||
endfunction | ||
|
||
" recursive_search_cmd | ||
" Returns TRUE if a command recursively searches by default. | ||
function! s:recursive_search_cmd(cmd_name) | ||
return a:cmd_name == 'ag' || a:cmd_name == 'rg' || a:cmd_name == 'ack' | ||
endfunction | ||
|
||
" grep#runGrep() | ||
" Run the specified grep command | ||
function! grep#runGrep(cmd_name, grep_cmd, action, ...) | ||
|
@@ -666,7 +677,7 @@ function! grep#runGrep(cmd_name, grep_cmd, action, ...) | |
echo "\r" | ||
endif | ||
|
||
if filenames == '' | ||
if filenames == '' && !s:recursive_search_cmd(a:grep_cmd) | ||
let filenames = input('Search in files: ', g:Grep_Default_Filelist, | ||
\ 'file') | ||
if filenames == '' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This break the Rgrep command, I always get this error when searching:
Error: Pattern '...' not found
My vim version:
:version VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 6 2017 02:39:16) macOS version Included patches: 1-1272