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

Cannot search for regexp spanning multiples lines via counsel-projectile-rg #166

Open
nordlow opened this issue Aug 11, 2020 · 1 comment

Comments

@nordlow
Copy link

nordlow commented Aug 11, 2020

I want to search for a regexp where the whitespace also includes newlines, in my case, to find C-style if-expressions that have an opening brace after the close parenthesis like

if (..) 
{
    ...

The command swiper-isearch understands \n in its minibuffer input and can match such multi-line patterns via for instance if ( ) \n { but counsel-projectile-rg can't with being fed the flag -U. It would be great if it did.

I guess this is related:

https://til.hashrocket.com/posts/9zneks2cbv-multiline-matches-with-ripgrep-rg

Update:

This call rg -U 'if \(.*\) *\n *\{' matches my needs

and in Elisp

(defun counsel-projectile-rg-multiline ()
  "Search the current project with rg pattern spanning multiple lines."
  (interactive)
  (counsel-projectile-rg "--multiline"))

with minibuffer input static if ( ) \n \{ works. Is it standard to have to backquote curly braces in Ivy/Projectile-style searches?

It's not needed with Swiper so I guess we shouldn't need to do that here either for interface consistency.

@ericdanan
Copy link
Owner

I don't intensively search for regexps in ivy/swiper so am not sure whether it's standard to backquote curly braces. In any case I think counsel-projectile probably doesn't play any part in this because counsel-projectile-rg essentially relies on counsel-rg. You could confirm this by trying your search in counsel-rg.

The difference between counsel-rg and swiper-isearch could come from the way rg processes the regexp it receives from counsel-rg I imagine. Whether or not this is something that counsel-rg should address I don't know. I would suggest to submit the issue on the swiper repo.

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

2 participants