Skip to content

Commit a450ae8

Browse files
committed
feat(toggle_checkbox) transform non-checkbox line into a checkbox
1 parent 8ea05a3 commit a450ae8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lua/obsidian/util.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,9 @@ end
478478
util.toggle_checkbox = function()
479479
local line_num = unpack(vim.api.nvim_win_get_cursor(0)) -- 1-indexed
480480
local line = vim.api.nvim_get_current_line()
481-
if string.match(line, "^%s*- %[ %].*") then
481+
if not string.match(line, "^%s*- %[.*") then
482+
line = string.gsub(line, "^([ ]*)", "%1- [ ] ")
483+
elseif string.match(line, "^%s*- %[ %].*") then
482484
line = util.string_replace(line, "- [ ]", "- [x]", 1)
483485
else
484486
for check_char in iter { "x", "~", ">", "-" } do

0 commit comments

Comments
 (0)