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

feat: Visual checkbox toggle

Open kaymmm opened this issue 2 years ago • 4 comments

this addresses #89

Calling :'<,'>ToggleCheckboxVisual with a visual selection toggles all the checkboxes in the selection.

Adds the mapping vnoremap <leader>x to call the new function.

It also tweaks the toggle checkbox function to accept a line number rather than have it operate on the current line.

kaymmm avatar Oct 08 '22 21:10 kaymmm

This looks good to me!

Not sure why the tests are not passing though - worth investigating. I've fixed the timeout issues in CI so this is likely a real failure.

Locally I was getting better results when using V (for LINE Visual mode as opposed to v)

    vim.normal 'j'
    vim.normal 'V'
    vim.normal '2j'
    vim.command 'ToggleCheckboxVisual'

But it still didn't select the 3rd checkbox - not sure if that's a bug.

Side note: I was thinking of changing the default toggle checkbox mapping though to <leader>xb - the reason is that the current mapping has a delay if the user already has <leader>x? where ? stands for any other character.

Vim will wait in this case for the next character for a bit which can be annoying. Setting it as <leader>xb solves the issue.

dkarter avatar Oct 08 '22 23:10 dkarter

The test is failing correctly. I just realized that the plugin is working "correctly" in that it toggles the parent (on) first, which toggles the child (on), but then the child gets toggled (off), which triggers the parent to toggle (off). It's unintuitive and the wrong behavior for what one would expect. Will need to rethink the logic here before merging.

kaymmm avatar Oct 08 '22 23:10 kaymmm

I can't figure out why the test I put together for this is failing, but the function seems to be working correctly now. I can't tell if the input I'm sending to the test is bad or if there's some reason why the function is not working as intended.

kaymmm avatar Oct 09 '22 00:10 kaymmm

Could you resolve conflicts and check if the tests still fail? If they do, could you post the failures here?

I can help debug and get this in

harshad1 avatar Mar 08 '24 07:03 harshad1