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,15 +588,22 @@ 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)
|
||||||
"set state and set the parents states recursively
|
else
|
||||||
let state_changed = s:set_state(a:item, new_rate)
|
let rate = s:get_rate(a:item)
|
||||||
if state_changed
|
if rate > 0 && rate < 100
|
||||||
call s:update_state(s:get_parent(a:item))
|
call s:set_state_recursively(a:item, 0)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endfunction "}}}
|
endfunction "}}}
|
||||||
|
|
||||||
|
function! s:set_state_recursively(item, new_rate) "{{{
|
||||||
|
let state_changed = s:set_state(a:item, a:new_rate)
|
||||||
|
if state_changed
|
||||||
|
call s:update_state(s:get_parent(a:item))
|
||||||
|
endif
|
||||||
|
endfunction "}}}
|
||||||
|
|
||||||
"Creates checkbox in a list item.
|
"Creates checkbox in a list item.
|
||||||
"Returns: 1 if successful
|
"Returns: 1 if successful
|
||||||
function! s:create_cb(item) "{{{
|
function! s:create_cb(item) "{{{
|
||||||
|
Loading…
Reference in New Issue
Block a user