diff options
| author | jdhao <jdhao@hotmail.com> | 2023-09-01 00:23:55 +0200 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2023-09-01 00:26:08 +0200 |
| commit | 359621b126507f7ff5dbbb017004721a54e6a89d (patch) | |
| tree | 9abe8299032c5697b9044f72ef006378a568c70d /lua/custom-autocmd.lua | |
| parent | 4dc2d9575bb35f5a3951d1289c02d1826ad72eb2 (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.lua | 4 |
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, }) |
