1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

fix multi visual line delete issue

For TextYankPost event, it includes both yank and delete, we should only
restore cursor position for yank, not for delete. Otherwise, it messes
up with text deletion when you visually select multiple lines and delete
them. See also issue reported here: https://github.com/jdhao/nvim-config/pull/222#issuecomment-1698634645
This commit is contained in:
jdhao 2023-09-01 00:23:55 +02:00
parent 4dc2d9575b
commit 359621b126

View File

@ -38,7 +38,9 @@ api.nvim_create_autocmd("TextYankPost", {
pattern = "*",
group = yank_group,
callback = function(ev)
vim.fn.setpos('.', vim.g.current_cursor_pos)
if vim.v.event.operator == 'y' then
vim.fn.setpos('.', vim.g.current_cursor_pos)
end
end,
})