-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #100 to correctly mark parent checkbox #101
base: master
Are you sure you want to change the base?
fix #100 to correctly mark parent checkbox #101
Conversation
Code is commented since the math is a bit tricky and not intuitive. And vimscript doesn't like floating point calculations
Thanks for the PR @mstojanovic! Would be good to add a snapshot test to spec/checkboxes_spec.rb that would confirm what would happen at each step, something along these lines: it 'toggle a checkbox step wise for 6 bullets' do
filename = "#{SecureRandom.hex(6)}.txt"
write_file(filename, <<-TEXT)
# Hello there
- [ ] top bullet
- [ ] first bullet
- [ ] second bullet
- [ ] third bullet
- [ ] fourth bullet
- [ ] fifth bullet
- [ ] sixth bullet
TEXT
vim.edit filename
vim.command "let g:bullets_checkbox_markers=' .:oOX'"
vim.normal '2j'
vim.command 'ToggleCheckbox'
vim.write
file_contents = IO.read(filename)
# 1/6 = 16%
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
# Hello there
- [.] top bullet
- [X] first bullet
- [ ] second bullet
- [ ] third bullet
- [ ] fourth bullet
- [ ] fifth bullet
- [ ] sixth bullet
TEXT
vim.normal 'j'
vim.command 'ToggleCheckbox'
vim.write
file_contents = IO.read(filename)
# 2/6 = 33%
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
# Hello there
- [:] top bullet
- [X] first bullet
- [X] second bullet
- [ ] third bullet
- [ ] fourth bullet
- [ ] fifth bullet
- [ ] sixth bullet
TEXT
vim.normal 'j'
vim.command 'ToggleCheckbox'
vim.write
file_contents = IO.read(filename)
# 3/6 = 50%
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
# Hello there
- [:] top bullet
- [X] first bullet
- [X] second bullet
- [X] third bullet
- [ ] fourth bullet
- [ ] fifth bullet
- [ ] sixth bullet
TEXT
vim.normal 'j'
vim.command 'ToggleCheckbox'
vim.write
file_contents = IO.read(filename)
# 4/6 = 66%
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
# Hello there
- [o] top bullet
- [X] first bullet
- [X] second bullet
- [X] third bullet
- [X] fourth bullet
- [ ] fifth bullet
- [ ] sixth bullet
TEXT
vim.normal 'j'
vim.command 'ToggleCheckbox'
vim.write
file_contents = IO.read(filename)
# 5/6 = 83%
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
# Hello there
- [O] top bullet
- [X] first bullet
- [X] second bullet
- [X] third bullet
- [X] fourth bullet
- [X] fifth bullet
- [ ] sixth bullet
TEXT
vim.normal 'j'
vim.command 'ToggleCheckbox'
vim.write
file_contents = IO.read(filename)
# 6/6 = 100%
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
# Hello there
- [X] top bullet
- [X] first bullet
- [X] second bullet
- [X] third bullet
- [X] fourth bullet
- [X] fifth bullet
- [X] sixth bullet
TEXT
end |
on it, i will do it asap just to clear one thing so that it makes more sense to all the users.
b) left border included [75,100>
|
@mstojanovic This still merges and passes existing tests. Do you plan to add tests or should I just merge it? |
Code is commented since the math is a bit tricky and not intuitive. And
vimscript doesn't like floating point calculations