clear a [.] or [o] or [O] item if it has no more children after moving
This commit is contained in:
parent
c036ac34c9
commit
eb44af27c2
@ -484,7 +484,7 @@ function! s:adjust_numbered_list(item, all, recursive) "{{{
|
|||||||
endwhile
|
endwhile
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
"Returns: the (rounded) rate of [X] checked child items in percent
|
"Returns: the (rounded) rate of checkboxed list item in percent
|
||||||
function! s:get_rate(item) "{{{
|
function! s:get_rate(item) "{{{
|
||||||
if a:item.type == 0 || a:item.cb == ''
|
if a:item.type == 0 || a:item.cb == ''
|
||||||
return -1
|
return -1
|
||||||
@ -588,13 +588,20 @@ function! s:update_state(item) "{{{
|
|||||||
|
|
||||||
if count_children_with_cb > 0
|
if count_children_with_cb > 0
|
||||||
let new_rate = sum_children_rate / count_children_with_cb
|
let new_rate = sum_children_rate / count_children_with_cb
|
||||||
|
call s:set_state_recursively(a:item, new_rate)
|
||||||
|
else
|
||||||
|
let rate = s:get_rate(a:item)
|
||||||
|
if rate > 0 && rate < 100
|
||||||
|
call s:set_state_recursively(a:item, 0)
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
"set state and set the parents states recursively
|
function! s:set_state_recursively(item, new_rate) "{{{
|
||||||
let state_changed = s:set_state(a:item, new_rate)
|
let state_changed = s:set_state(a:item, a:new_rate)
|
||||||
if state_changed
|
if state_changed
|
||||||
call s:update_state(s:get_parent(a:item))
|
call s:update_state(s:get_parent(a:item))
|
||||||
endif
|
endif
|
||||||
endif
|
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
"Creates checkbox in a list item.
|
"Creates checkbox in a list item.
|
||||||
|
Loading…
Reference in New Issue
Block a user