mirror of
https://github.com/opdavies/toggle-checkbox.nvim.git
synced 2025-03-13 05:26:56 +00:00
feat: set the cursor to the original position
This commit is contained in:
parent
c8da955004
commit
2a4c5b0682
|
@ -16,11 +16,13 @@ local M = {}
|
|||
M.check = function()
|
||||
local new_line = current_line:gsub("%[ %]", checked_checkbox)
|
||||
vim.api.nvim_buf_set_lines(bufnr, cursor[1] - 1, cursor[1], false, { new_line })
|
||||
vim.api.nvim_win_set_cursor(0, cursor)
|
||||
end
|
||||
|
||||
M.uncheck = function()
|
||||
local new_line = current_line:gsub("%[" .. checked_character .. "%]", unchecked_checkbox)
|
||||
vim.api.nvim_buf_set_lines(bufnr, cursor[1] - 1, cursor[1], false, { new_line })
|
||||
vim.api.nvim_win_set_cursor(0, cursor)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Reference in a new issue