bullets.vim icon indicating copy to clipboard operation
bullets.vim copied to clipboard

Bug: Nested to-do list prematurely marked as complete

Open yutanagano opened this issue 11 months ago • 9 comments

Thanks for the lovely plugin. I have noticed that when checking off tasks in nested to-do lists, the parent list level can become prematurely marked as "complete" even if not all of its subtasks are such.

To reproduce

  1. Make a nested to-do list with many subtasks (e.g. 10):
- [ ] some task:
    - [ ] subtask 1
    - [ ] subtask 2
    - [ ] subtask 3
    - [ ] subtask 4
    - [ ] subtask 5
    - [ ] subtask 6
    - [ ] subtask 7
    - [ ] subtask 8
    - [ ] subtask 9
    - [ ] subtask 10 
  1. Tick off subtasks and at the 8th subtask completed, the parent task is incorrectly marked as done
- [X] some task:
    - [X] subtask 1
    - [X] subtask 2
    - [X] subtask 3
    - [X] subtask 4
    - [X] subtask 5
    - [X] subtask 6
    - [X] subtask 7
    - [X] subtask 8
    - [ ] subtask 9
    - [ ] subtask 10 

Expected behaviour

I feel the parent task should remain at the final "partially complete" state until reaching 100% of its subtasks being completed. If I understand correctly this is what the authors mean it to do as well, since the documentation states as such.

yutanagano avatar Jan 30 '25 16:01 yutanagano

Pretty sure the issue is the usage of ceil here https://github.com/bullets-vim/bullets.vim/blob/master/plugin/bullets.vim#L1395

harshad1 avatar Feb 22 '25 21:02 harshad1

Yeah. Dropping that fixes things. Could you create a PR?

harshad1 avatar Feb 22 '25 21:02 harshad1

@harshad1 there is already a PR. removing ceil fix the issue from @yutanagano but when the scenario is like below it leave the parent checkbox empty.

- [ ] some task:
    - [X] subtask 1
    - [ ] subtask 2
    - [ ] subtask 3
    - [ ] subtask 4
    - [ ] subtask 5
    - [ ] subtask 6
    - [ ] subtask 7
    - [ ] subtask 8
    - [ ] subtask 9
    - [ ] subtask 10 

i think it should be like this:

- [.] some task:
    - [X] subtask 1
    - [ ] subtask 2
    - [ ] subtask 3
    - [ ] subtask 4
    - [ ] subtask 5
    - [ ] subtask 6
    - [ ] subtask 7
    - [ ] subtask 8
    - [ ] subtask 9
    - [ ] subtask 10 

hoarse-boy avatar Mar 03 '25 04:03 hoarse-boy

I'll take a look at the math and potentially merge the fix

harshad1 avatar Mar 03 '25 04:03 harshad1

@hoarse-boy would you be willing to add a test to that PR? It is described in the comments.

harshad1 avatar Mar 04 '25 22:03 harshad1

@hoarse-boy would you be willing to add a test to that PR? It is described in the comments.

@harshad1 sorry for the late reply.

you mean the comments in that PR?

btw, i have never code vimscript as i'm a nvim lua user so maybe it will take quite some time. i will take a look later when i have the time.

hoarse-boy avatar Mar 06 '25 14:03 hoarse-boy

The tests are actually in Ruby. If you look at the comments and the existing tests they're pretty easy to write.

I help maintain this project and I have never written Ruby outside of the tests here :)

harshad1 avatar Mar 06 '25 20:03 harshad1

The tests are actually in Ruby. If you look at the comments and the existing tests they're pretty easy to write.

I help maintain this project and I have never written Ruby outside of the tests here :)

@harshad1 i see, i could try. never done ruby though. i will check it out later.

hoarse-boy avatar Mar 07 '25 02:03 hoarse-boy

Also see #101 and #164

harshad1 avatar Dec 06 '25 18:12 harshad1