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

Allow to parse search phrase in quotes "as is" #54

Open
mambusskruj opened this issue Apr 4, 2023 · 3 comments · May be fixed by #76
Open

Allow to parse search phrase in quotes "as is" #54

mambusskruj opened this issue Apr 4, 2023 · 3 comments · May be fixed by #76

Comments

@mambusskruj
Copy link

mambusskruj commented Apr 4, 2023

Let's say I want to search for parameter --jobs in files. And for that I need to escape dashes with backslashes even while I use quotes for search phrase (like this "\-\-jobs").

So I propose to parse characters "as is" in quotes for search phrase.
Example: for "--jobs" prompt -> search phrase will be --jobs

@mambusskruj mambusskruj changed the title Allow to parse dashes in quotes "as is" Allow to parse search phrase quotes "as is" Apr 4, 2023
@mambusskruj mambusskruj changed the title Allow to parse search phrase quotes "as is" Allow to parse search phrase in quotes "as is" Apr 4, 2023
@notpeelz
Copy link

notpeelz commented Aug 25, 2023

rg "--jobs" is the same as rg --jobs, which results in this error:

error: Found argument '--jobs' which wasn't expected, or isn't valid in this context

You need to tell the program to stop parsing the options list, i.e. rg -- --jobs

You can use this function instead of the default quote_prompt:

local action_state = require("telescope.actions.state")
local function quote_prompt(bufnr)
  local picker = action_state.get_current_picker(bufnr)
  local prompt = picker:_get_prompt()
  prompt = vim.trim(prompt)
  prompt = "-- \"" .. prompt:gsub("\"", "\\\"") .. "\""
  picker:set_prompt(prompt)
  vim.cmd.normal{ "I", bang = true }
end
lga.mp4

@mambusskruj
Copy link
Author

@notpeelz wow, thank you so much!

@weeman1337
Copy link
Collaborator

I have re-opened the issue. Searching for --jobs should work. The comment is a possible workaround. I will take a look and add something to the plugin.

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