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

"Automatic paste after yanking" snippet fails for custom text objects #253

Open
filyp opened this issue Oct 23, 2024 · 0 comments
Open

"Automatic paste after yanking" snippet fails for custom text objects #253

filyp opened this issue Oct 23, 2024 · 0 comments

Comments

@filyp
Copy link

filyp commented Oct 23, 2024

The snippet from readme:

vim.api.nvim_create_augroup('LeapRemote', {})
vim.api.nvim_create_autocmd('User', {
  pattern = 'RemoteOperationDone',
  group = 'LeapRemote',
  callback = function (event)
    -- Do not paste if some special register was in use.
    if vim.v.operator == 'y' and event.data.register == '"' then
      vim.cmd('normal! p')
    end
  end,
})

fails to paste if I yanked using some custom text object, for example indent object defined by michaeljsmith/vim-indent-object or some objects from targets.vim ((, [, b objects which are redefined by targets.vim I think - only happens with targets.vim enabled). It happens even if I remove this if statement and always try to paste.

I isolated that this happens due to this line, concretely ((mode0 == "v") or (mode0 == "V") or (mode0 == "\22")) and (key == mode0) in the case of target.vim, and (key == vim.keycode("<esc>")) in the case of vim-indent-object, marking that the operation was cancelled, while it wasn't.

For vim-indent-object I can see why it happens, it defines things like vnoremap <silent>ii :<C-u>cal <Sid>HandleTextObjectMapping(1, 0, 1, [line("'<"), line("'>"), col("'<"), col("'>")])<CR><Esc>gv.

For now I just disabled locally this cancellation line and I'm satisfied with that.

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

No branches or pull requests

1 participant