mirror of
https://github.com/junegunn/fzf.vim.git
synced 2025-12-06 04:34:26 +08:00
Use -- before the search pattern for Ag, Rg, etc. (#1012)
Before this patch, a search pattern starting with a dash like `:Rg -bang` would fail (or exhibit the wrong behaviour) because it would be treated as a option. However, this case is very common when searching for ->member in a project in C, C++, PHP, etc. Co-authored-by: Alexandre Perrin <alex@atipik.ch>
This commit is contained in:
@@ -228,7 +228,7 @@ predefined `Ag` or `Rg` using `fzf#vim#grep`.
|
||||
```vim
|
||||
command! -bang -nargs=* GGrep
|
||||
\ call fzf#vim#grep(
|
||||
\ 'git grep --line-number '.shellescape(<q-args>), 0,
|
||||
\ 'git grep --line-number -- '.shellescape(<q-args>), 0,
|
||||
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
|
||||
```
|
||||
|
||||
@@ -242,7 +242,7 @@ the spec argument to `fzf#vim#preview`.
|
||||
```vim
|
||||
command! -bang -nargs=* Rg
|
||||
\ call fzf#vim#grep(
|
||||
\ 'rg --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>), 1,
|
||||
\ 'rg --column --line-number --no-heading --color=always --smart-case -- '.shellescape(<q-args>), 1,
|
||||
\ fzf#vim#with_preview(), <bang>0)
|
||||
```
|
||||
|
||||
@@ -267,7 +267,7 @@ a "fuzzy finder".
|
||||
|
||||
```vim
|
||||
function! RipgrepFzf(query, fullscreen)
|
||||
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
|
||||
let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case -- %s || true'
|
||||
let initial_command = printf(command_fmt, shellescape(a:query))
|
||||
let reload_command = printf(command_fmt, '{q}')
|
||||
let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
|
||||
|
||||
Reference in New Issue
Block a user