aboutsummaryrefslogtreecommitdiff
path: root/lua/custom-autocmd.lua
diff options
context:
space:
mode:
authorjdhao <jdhao@hotmail.com>2023-09-01 00:23:55 +0200
committerjdhao <jdhao@hotmail.com>2023-09-01 00:26:08 +0200
commit359621b126507f7ff5dbbb017004721a54e6a89d (patch)
tree9abe8299032c5697b9044f72ef006378a568c70d /lua/custom-autocmd.lua
parent4dc2d9575bb35f5a3951d1289c02d1826ad72eb2 (diff)
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
Diffstat (limited to 'lua/custom-autocmd.lua')
-rw-r--r--lua/custom-autocmd.lua4
1 files changed, 3 insertions, 1 deletions
diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua
index bfa2e8e..83a1a48 100644
--- a/lua/custom-autocmd.lua
+++ b/lua/custom-autocmd.lua
@@ -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,
})