Never alter a checkbox if it has no children with checkboxes
This commit is contained in:
parent
c6e110a368
commit
911f2d4a8c
@ -546,8 +546,8 @@ function! s:update_state(item) "{{{
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let sum_siblings = 0
|
let sum_children_rate = 0
|
||||||
let count_siblings = 0
|
let count_children_with_cb = 0
|
||||||
|
|
||||||
let child_item = s:get_first_child(a:item)
|
let child_item = s:get_first_child(a:item)
|
||||||
|
|
||||||
@ -556,18 +556,20 @@ function! s:update_state(item) "{{{
|
|||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
if child_item.cb != ''
|
if child_item.cb != ''
|
||||||
let count_siblings += 1
|
let count_children_with_cb += 1
|
||||||
let sum_siblings += s:get_rate(child_item)
|
let sum_children_rate += s:get_rate(child_item)
|
||||||
endif
|
endif
|
||||||
let child_item = s:get_next_child_item(a:item, child_item)
|
let child_item = s:get_next_child_item(a:item, child_item)
|
||||||
endwhile
|
endwhile
|
||||||
|
|
||||||
let new_rate = count_siblings > 0 ? sum_siblings / count_siblings : 0
|
if count_children_with_cb > 0
|
||||||
|
let new_rate = sum_children_rate / count_children_with_cb
|
||||||
|
|
||||||
"set state and set the parents states recursively
|
"set state and set the parents states recursively
|
||||||
let state_changed = s:set_state(a:item, new_rate)
|
let state_changed = s:set_state(a:item, 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 "}}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user