fix: replace vim.fn.strbytes with Lua # operator

main
borja (aider) 2 months ago
parent 7df445bd74
commit d1a2f0d378

@ -67,7 +67,7 @@ local function add_todo_insert_mode()
-- Set cursor position: 1-based row, 0-based byte column -- Set cursor position: 1-based row, 0-based byte column
-- Position cursor right after the "] " -- Position cursor right after the "] "
local cursor_col_bytes = vim.fn.strbytes(details.indent .. use_marker .. " [ ] ") local cursor_col_bytes = #(details.indent .. use_marker .. " [ ] ") -- Use Lua # operator
vim.api.nvim_win_set_cursor(0, { lnum, cursor_col_bytes }) vim.api.nvim_win_set_cursor(0, { lnum, cursor_col_bytes })
end end
@ -84,7 +84,7 @@ local function add_todo_append_mode()
-- Set cursor position: 1-based row, 0-based byte column -- Set cursor position: 1-based row, 0-based byte column
-- Position cursor at the very end of the line content -- Position cursor at the very end of the line content
local cursor_col_bytes = vim.fn.strbytes(new_line) local cursor_col_bytes = #new_line -- Use Lua # operator
vim.api.nvim_win_set_cursor(0, { lnum, cursor_col_bytes }) vim.api.nvim_win_set_cursor(0, { lnum, cursor_col_bytes })
end end
@ -104,7 +104,7 @@ local function add_todo_new_line_mode()
-- Set cursor position: 1-based row (lnum + 1), 0-based byte column -- Set cursor position: 1-based row (lnum + 1), 0-based byte column
-- Position cursor at the end of the new line (after "] ") -- Position cursor at the end of the new line (after "] ")
local cursor_col_bytes = vim.fn.strbytes(new_line_content) local cursor_col_bytes = #new_line_content -- Use Lua # operator
vim.api.nvim_win_set_cursor(0, { lnum + 1, cursor_col_bytes }) vim.api.nvim_win_set_cursor(0, { lnum + 1, cursor_col_bytes })
end end

Loading…
Cancel
Save