@@ -89,7 +89,6 @@ if !exists('g:bullets_checkbox_markers')
8989 " You can disable partial completion markers like this:
9090 " let g:bullets_checkbox_markers = ' X'
9191endif
92- let s: checkbox_markers = split (g: bullets_checkbox_markers ,' \zs' )
9392
9493if ! exists (' g:bullets_checkbox_partials_toggle' )
9594 " Should toggling on a partially completed checkbox set it to on (1), off
@@ -221,7 +220,7 @@ fun! s:match_checkbox_bullet_item(input_text)
221220 " default ' ', 'x', and 'X'
222221 let l: checkbox_bullet_regex =
223222 \ ' \v(^(\s*)([-\*] \[(['
224- \ . join ( s: checkbox_markers , ' ' )
223+ \ . g: bullets_checkbox_markers
225224 \ . ' xX])?\])(\s+))(.*)'
226225 let l: matches = matchlist (a: input_text , l: checkbox_bullet_regex )
227226
@@ -455,7 +454,11 @@ fun! s:insert_new_bullet()
455454 elseif ! (l: bullet .bullet_type == # ' abc' && s: abc2dec (l: bullet .bullet) + 1 > s: abc_max )
456455
457456 let l: next_bullet = s: next_bullet_str (l: bullet )
458- let l: next_bullet_list = [s: pad_to_length (l: next_bullet , l: bullet .bullet_length)]
457+ if l: bullet .bullet_type == # ' chk'
458+ let l: next_bullet_list = [l: next_bullet ]
459+ else
460+ let l: next_bullet_list = [s: pad_to_length (l: next_bullet , l: bullet .bullet_length)]
461+ endif
459462
460463 " prepend blank lines if desired
461464 if g: bullets_line_spacing > 1
@@ -531,23 +534,24 @@ fun! s:toggle_checkbox(lnum)
531534 return -1
532535 endif
533536
534- let l: partial_markers = join (s: checkbox_markers [1 :-2 ], ' ' )
537+ let l: checkbox_markers = split (g: bullets_checkbox_markers , ' \zs' )
538+ let l: partial_markers = join (l: checkbox_markers [1 :-2 ], ' ' )
535539 if g: bullets_checkbox_partials_toggle > 0
536540 \ && l: checkbox_content = ~# ' \v[' . l: partial_markers . ' ]'
537541 " Partially complete
538542 let l: marker = g: bullets_checkbox_partials_toggle ?
539- \ s : checkbox_markers [-1 ] :
540- \ s : checkbox_markers [0 ]
541- elseif l: checkbox_content = ~# ' \v[ ' . s : checkbox_markers [0 ] . ' ]'
542- let l: marker = s : checkbox_markers [-1 ]
543- elseif l: checkbox_content = ~# ' \v[xX' . s : checkbox_markers [-1 ] . ' ]'
544- let l: marker = s : checkbox_markers [0 ]
543+ \ l : checkbox_markers [-1 ] :
544+ \ l : checkbox_markers [0 ]
545+ elseif l: checkbox_content = ~# ' \v[ ' . l : checkbox_markers [0 ] . ' ]'
546+ let l: marker = l : checkbox_markers [-1 ]
547+ elseif l: checkbox_content = ~# ' \v[xX' . l : checkbox_markers [-1 ] . ' ]'
548+ let l: marker = l : checkbox_markers [0 ]
545549 else
546550 return -1
547551 endif
548552
549553 call s: set_checkbox (l: lnum , l: marker )
550- return l: marker == ? s : checkbox_markers [-1 ]
554+ return l: marker == ? l : checkbox_markers [-1 ]
551555endfun
552556
553557fun ! s: set_checkbox (lnum, marker)
@@ -612,9 +616,10 @@ fun! s:set_child_checkboxes(lnum, checked)
612616
613617 let l: children = s: get_children_line_numbers (a: lnum )
614618 if ! empty (l: children )
619+ let l: checkbox_markers = split (g: bullets_checkbox_markers , ' \zs' )
615620 for l: child in l: children
616- let l: marker = a: checked ? s : checkbox_markers [-1 ] :
617- \ s : checkbox_markers [0 ]
621+ let l: marker = a: checked ? l : checkbox_markers [-1 ] :
622+ \ l : checkbox_markers [0 ]
618623 call s: set_checkbox (l: child , l: marker )
619624 call s: set_child_checkboxes (l: child , a: checked )
620625 endfor
@@ -1217,22 +1222,23 @@ fun! s:sibling_checkbox_status(lnum)
12171222 let l: siblings = s: get_sibling_line_numbers (a: lnum )
12181223 let l: num_siblings = len (l: siblings )
12191224 let l: checked = 0
1225+ let l: checkbox_markers = split (g: bullets_checkbox_markers , ' \zs' )
12201226 for l: lnum in l: siblings
12211227 let l: indent = indent (l: lnum )
12221228 let l: bullet = s: closest_bullet_types (l: lnum , l: indent )
12231229 let l: bullet = s: resolve_bullet_type (l: bullet )
12241230 if ! empty (l: bullet ) && has_key (l: bullet , ' checkbox_marker' )
12251231 let l: checkbox_content = l: bullet .checkbox_marker
12261232
1227- if l: checkbox_content = ~# ' \v[xX' . s : checkbox_markers [-1 ] . ' ]'
1233+ if l: checkbox_content = ~# ' \v[xX' . l : checkbox_markers [-1 ] . ' ]'
12281234 " Checked
12291235 let l: checked += 1
12301236 endif
12311237 endif
12321238 endfor
1233- let l: divisions = len (s : checkbox_markers ) - 1.0
1239+ let l: divisions = len (l : checkbox_markers ) - 1.0
12341240 let l: completion = float2nr (ceil (l: divisions * l: checked / l: num_siblings ))
1235- return s : checkbox_markers [l: completion ]
1241+ return l : checkbox_markers [l: completion ]
12361242endfun
12371243
12381244" ------------------------------------------------------- }}}
0 commit comments