-
Notifications
You must be signed in to change notification settings - Fork 56
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
text-objects do not preserve v:register for custom operators #253
Comments
@lacygoill: Thank you for your thorough analysis! I'm happy to see that you're trying to implement a custom text object with targets.vim. Would you mind sharing what you are planning to add? I'm just curious. I'm currently finishing up work for wellle/context.vim#40 and will try to get back to this issue afterwards. |
For now, I'm not trying to implement any custom text-object. I'm just using the default text-objects provided by targets.vim. They work fine with builtin operators (like I found this issue while I was using a custom I fixed the issue by saving |
Thanks, understood 👍 |
Describe the bug
A custom text-object provided by targets.vim does not preserve
v:register
for custom operators.To Reproduce
Run this shell command:
You'll need to replace
/path/to/targets.vim
with the path to your plugin's local installation."
is echo'ed (run:mess
if you missed it).Expected behavior
a
is echo'ed, because the custom operator mapped to<C-b>
was prefixed by"a
.Environment
Additional context
This breaks a custom operator which needs to read or write into
v:register
, when the latter is different than"
.I don't know how targets.vim implements its text-objects including
i'
, but for the current issue, let's assume that it could be grossly simplified like this:If this assumption is correct, you can reproduce the issue with this other minimal example, which doesn't require targets.vim:
Notice how – again – Vim echo'es
"
instead ofa
. That's because when the:ono
mapping is expanded,:norm
is executed, and the latter resetsv:register
to"
.One solution is to make the text-object pass
v:register
to the opfunc manually:Example:
For more info, see this question on vi.stackexchange.com, and this Vim issue.
Btw, if you agree with this analysis, I think it would help if you could leave a comment on the aforementioned issue report, explaining that you currently need to find work arounds; whereas if it was fixed directly in Vim, it would automatically fix your plugin and probably many others. Right now, the issue didn't get much traction; it has not even been mentioned in Vim's todo list.
The text was updated successfully, but these errors were encountered: