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

Smarter auto-quoting #6

Closed
jesseleite opened this issue Nov 22, 2021 · 3 comments · Fixed by #13
Closed

Smarter auto-quoting #6

jesseleite opened this issue Nov 22, 2021 · 3 comments · Fixed by #13

Comments

@jesseleite
Copy link
Contributor

jesseleite commented Nov 22, 2021

Firstly, thanks @weeman1337 for taking the time with this extension! Life got busy, and my PR fell by the wayside 😂

Anyway, one of the features I had started to implement in my PR was auto-quoting. For example in your extension, I can't search a string like function create unless I wrap it in quotes 'function create' first.

I personally think spaces should be treated as part of the search query, unless command line options are needed, or quotes are part of the query you are trying to search...

User's query: Runs: Note:
function create rg 'function create' Quotes not necessary
func.*create rg 'func.*create' Quotes not necessary
it's a wonderful life rg "it's a wonderful life" If only one quote instead of pair, quotes not necessary
'function create' rg 'function create' Don't auto-quote if they explicitly wrap with quotes
"function create" rg "function create" Don't auto-quote if they explicitly wrap with quotes
-uu 'func.*create' rg -uu 'func.*create' Don't auto-quote if they pass opts/args
'func.*create' vendor rg 'func.*create' vendor Don't auto-quote if they pass opts/args

Note: The it's a wonderful life example might be the most subjective and/or complicated one. The way I had implemented it in https://github.com/jesseleite/vim-agriculture was, if a single quote is used in the query at all, then don't auto-quote anything, and expect the user to wrap the query in quotes. It would be neat if it could detect single quotes vs quote pairs, but I understand if we skip on that one.

Curious on your thoughts? ❤️

@weeman1337
Copy link
Collaborator

Thanks for the detailed explanation. Currently it is really "raw" because it parses the prompt like shell args.

What about this?:

  • quote the entire prompt if not starting with -, ', "
    • Should quotes in between be escaped (e.g. function "create"function \"create")?
  • else parse like shell args

Covers everything inlcuding the wonderful life ;)

One common search I am running is somestring insomedir. With „smart auto-quoting“ this has to be "somestring" insomedir. I would prefer keeping the shell like argument parsing → It should be configurable (enabled by default?).

@jesseleite
Copy link
Contributor Author

quote the entire prompt if not starting with -, ', "

That sounds great to me!

It should be configurable (enabled by default?)

Just my two cents, but I do think smart-quoting should be enabled by default personally; No other telescope prompt expects you to quote simple multiple word queries like this...

image

Anyway, appreciate you taking over this feature!

@weeman1337 weeman1337 mentioned this issue Apr 30, 2022
@weeman1337
Copy link
Collaborator

The auto-quoting can be tested in #13. Also happy for any PR feedback.

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

Successfully merging a pull request may close this issue.

2 participants