mirror of
https://github.com/opdavies/toggle-checkbox.nvim.git
synced 2025-11-11 12:18:45 +00:00
feat: set the cursor to the original position
This commit is contained in:
parent
c8da955004
commit
2a4c5b0682
1 changed files with 2 additions and 0 deletions
|
|
@ -16,11 +16,13 @@ local M = {}
|
||||||
M.check = function()
|
M.check = function()
|
||||||
local new_line = current_line:gsub("%[ %]", checked_checkbox)
|
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_buf_set_lines(bufnr, cursor[1] - 1, cursor[1], false, { new_line })
|
||||||
|
vim.api.nvim_win_set_cursor(0, cursor)
|
||||||
end
|
end
|
||||||
|
|
||||||
M.uncheck = function()
|
M.uncheck = function()
|
||||||
local new_line = current_line:gsub("%[" .. checked_character .. "%]", unchecked_checkbox)
|
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_buf_set_lines(bufnr, cursor[1] - 1, cursor[1], false, { new_line })
|
||||||
|
vim.api.nvim_win_set_cursor(0, cursor)
|
||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue