-
Notifications
You must be signed in to change notification settings - Fork 30
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
Ability to update prefills with visual selection #258
Comments
hi @mehalter, So the way visual selection currently works is a bit special in that depending on the engine (ripgrep/astgrep) we put in additional flags. For example, for ripgrep, we add I think what we can do though and would be the most flexible is expose a utility function to get the current visual selection as a string, that users can then pass to Implementation would look something like: function M.get_current_visual_selection()
local isVisualMode = vim.fn.mode():lower():find('v') ~= nil
if isVisualMode then
-- needed to make visual selection work
vim.cmd([[normal! vv]])
end
local selection_lines = utils.getVisualSelectionLines()
return vim.fn.join(selection_lines, '\n')
end So you would call it like: grugFar.update_instance_prefills('myinstance', { search = grugFar.get_current_visual_selection() }) The beauty of this is that you can modify it before passing it in or prefill some other input like replace. |
Oh yeah that looks great! |
done 😄 |
let me know if you see any issue, it was sort of hastily thrown in 😄 |
I'll let you know tomorrow when I mess around with it. Only thing that comes immediatly to mind is it seems like there might be a good way to interpolate this through the |
Those ones already use the util function, and are slightly different since they need to call on engine specific logic, but if there is a nice way to do it I am not against it… |
@MagicDuck I took a stab at this while also fixing a few bugs in the visual selection code. Mainly bugs in how the code was leaving visual mode which was exposed when using the PR #265 |
Thank you for those, I wish I could get more people like you, who create PRs instead of just asking, haha! |
No problem! Team work makes the dream work in the open-source community 🤗 |
I love the improvements to the API and particularly enjoy the ability to update the prefills of a given instance. Given that the prefilling with visual selection is a separate command, could there be an addition to the API to allow updating the prefills with the current visual selection as well?
The text was updated successfully, but these errors were encountered: