Skip to content

Commit b71d5dd

Browse files
authored
Merge pull request #76 from harshad1/handle_not_a_checkbox
Handle not a checkbox
2 parents 79317c5 + f8eb263 commit b71d5dd

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

plugin/bullets.vim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,10 @@ endfun
558558
fun! s:set_checkbox(lnum, marker)
559559
let l:initpos = getpos('.')
560560
let l:pos = s:find_checkbox_position(a:lnum)
561-
call s:replace_char_in_line(a:lnum, l:pos, a:marker)
562-
call setpos('.', l:initpos)
561+
if l:pos >= 0
562+
call s:replace_char_in_line(a:lnum, l:pos, a:marker)
563+
call setpos('.', l:initpos)
564+
endif
563565
endfun
564566

565567
fun! s:toggle_checkboxes_nested()

spec/checkboxes_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- [.] fourth bullet
3636
- [o] fifth bullet
3737
- [O] sixth bullet
38+
- not a checkbox
3839
TEXT
3940

4041
vim.edit filename
@@ -50,6 +51,8 @@
5051
vim.command 'ToggleCheckbox'
5152
vim.normal 'j'
5253
vim.command 'ToggleCheckbox'
54+
vim.normal 'j'
55+
vim.command 'ToggleCheckbox'
5356
vim.write
5457

5558
file_contents = IO.read(filename)
@@ -62,6 +65,7 @@
6265
- [X] fourth bullet
6366
- [X] fifth bullet
6467
- [X] sixth bullet
68+
- not a checkbox
6569
6670
TEXT
6771
end

0 commit comments

Comments
 (0)