Open fdschmidt93 opened 6 months ago
From the linked PR:
Also make it work better on a multiline selection.
This reminds me, we don't really support multi-line greps well. Pasting multi-line text into the prompt buffer is not really functional due to the nature of buftype='prompt'
but even if we were to use default_text
to get around this and pass multi-line text to rg, we're constrained by whether --multiline
flag is passed. And then the issue of properly escaping regex characters or passing --fixed-strings
comes up.
I think these factors, particularly the last one of escaping regex characters, makes inserting anything longer than <cword>
kind of user error-prone, or at the very least confusing. I'm not sure what the best mechanism is for making this user friendly and obvious. I think telescope-live-grep-args is probably better suited for something like this anyways.
Eg. If someone visually selects function()
and greps it (already possible with grep_string
), and they don't see any results not knowing you really need to grep for function\(\)
or pass --fixed-string
.
Yeah, there are a lot of wacky cases to consider. I guess that's why it is better left to the user. In other words, best approach is adding something like the above (plus considerations) somewhere clearly to the docs.
(Once the user is generally aware of limitations etc. it is however typically a very nice improvement over
Thanks to Shougo and zeertzjq we now have a proper function to get visual text in Neovim (nightly, for now).
and as used official in Neovim nightly here https://github.com/neovim/neovim/pull/27663/files
Is this something we would want
default_text
to, well, default to if the user launches a picker from visual mode anddefault_text
is unset?Pros:
live_grep
variant several times a dayCons:
""
or something of sorts.Putting this up for discussion. Happy to get thoughts and make a PR if desirable at least in some contexts :) (like adding it also to
live_grep
). Otherwise, we can also close this FR.