Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dwim operations with grep -rnH do not work #95

Closed
pierre-rouleau opened this issue Jan 11, 2023 · 2 comments
Closed

dwim operations with grep -rnH do not work #95

pierre-rouleau opened this issue Jan 11, 2023 · 2 comments

Comments

@pierre-rouleau
Copy link
Contributor

pierre-rouleau commented Jan 11, 2023

I wonder if something broke recently or if that ever worked, but when one of the fzf-grep-dwim or fzf-grep-dwim-with-narrowing is used while fzf/grep-command uses grep (as opposed to rg) the operation does not work.

The reason it does not work is the grep command requires a file pattern to search otherwise it searches from its stdin. The 'dwim' commands provide a pattern that the command can append to fzf/grep-command but grep does not see any file pattern. So the grep operation fails. If we change fzf/grep-command to use rg (ripgrep) then it works because ripgrep recusively searches all files (except the hidden ones) by default.

So... I wonder... Did these dwim commands ever worked with 'grep -rnH' , or did I break something?

@bling, do you know?

@pierre-rouleau pierre-rouleau changed the title dwim operations with grep -rnH does not work dwim operations with grep -rnH do not work Jan 11, 2023
@pierre-rouleau
Copy link
Contributor Author

@bling I pushed a potential work-around fix for that, at least allowing the dwim operations to work. It could probably be improved but it's better than nothing. See 96be397

bling pushed a commit that referenced this issue Jan 11, 2023
* Describe dwim with grep limitation. +1 optimization.

* Add fzf-find-in-buffer (by LiuYinCarl)

Add fzf-find-in-buffer originally proposed by LiuYinCarl in
#94

I modified the proposed code a little to adapt to the current code and added
protection against trying to search in a buffer that is not visiting a file,
an prompt to save the buffer if it has been modified.

* Fix issue #95: dwim with grep

A work-around fix for dwim operations using grep.  When a FZF grep with
specified text is executed, a file pattern of " *" is automatically appended
to the grep command, allowing the operation to proceed.
@pierre-rouleau
Copy link
Contributor Author

The latest pushed code fixes the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant