fix(format): stop deleting task bodies and everything else inside ## Tasks - #50
Merged
Merged
Conversation
…Tasks The section was rebuilt from the model, which holds checkbox lines, annotations and a note's first line only. It is now walked: the formatter regenerates what it can account for and copies every other line through.
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #49, same root cause. Found while fixing #48 and worse than it:
lash addmisattributed a task's body,lash formatdestroyed it — and the README tells people to runformat.The bug
#44 stopped
formatfrom deleting whole sections, by having it regenerate only the spans the model owns and copy the rest through. But the## Tasksspan was still rebuilt wholesale from the task tree, and the tree holds checkbox lines, their annotations, and the first line of each contextual note. Nothing else that lives in the section had anything to be rebuilt from, so it was deleted — exit code 0, "Formatted 1 file(s) successfully".The reported repro was a task body. The actual blast radius was larger:
---separators and comments### Subsectionheadings, whichsection_spanexplicitly supports and files routinely use to group tasksContextualNoterecords only the note's first lineFormatting this repo's own
lash.index.mdused to produce a 238-line diff, most of it deletion. It is 52 lines now, all of it label sorting.The fix
#44's rule applied one level down: walk the section's source, regenerate the lines the model can account for, copy every other line through.
formatis now the same rule at both levels — rebuild what the model owns, carry everything else.No new model state. Extending
TaskFileto carry bodies would have been a fourth thing to keep in sync with the source, which is the shape of bug this codebase keeps paying for (see the placement-count history in #43/#33/#48).The note handling is the part worth reviewing. Emitting a task's notes alongside the task looks right and is wrong: only a note's first line is in the model, so continuation lines get copied through where they sit while the first line is hoisted up to the task — stranding each note's text behind an unrelated bullet. Notes are anchored individually at their own source line instead. This was invisible in the small repro and obvious the moment the formatter was pointed at a real file.
Two guards on the walk:
format_filea source the model did not come from.Behavior change
Blank lines between tasks now survive. They belong to the author, and
lash addwrites one when it appends below a task with a body (#49).Verification
The formatter still normalizes everything it owns — auto-waive, status consistency, label sorting, indentation, trailing whitespace — around preserved bodies; there's a test asserting exactly that.
Tests added:
### Subsectionheadings survivelash formattests asserting the on-disk file, including--checkreporting a file with bodies as already formattedFull workspace suite, clippy and rustfmt clean.
Not doing
The lint rule suggested on #48. A misattributed body is syntactically indistinguishable from a correct one, so there is nothing for the linter to check against.