My version of Toggle Tasks

Toggle task marks on selected lines, as follows:

  • If a line is checked, it will become unchecked.
  • If a line is unchecked, it will become checked.
  • If a (non-blank) line has no checkbox, it will be given one (unchecked), along with a list-hyphen if necessary.
  • Blank lines will be left untouched.

(The built-in version of this action duplicates list-hyphens on lines without a checkbox, which annoyed me.)