Repository navigation
Commit ef926b7
fix(md022): use the same list test below a heading in check and fix (#790)
On `text\n# Heading\n - deeper\n`, `rumdl check -e MD022` reports exactly one
warning, "Expected 1 blank line above heading", and offers one fix. `rumdl check
--fix -e MD022` then prints "Fixed 1/1 issues" but writes
`text\n\n# Heading\n\n - deeper\n` - a blank line above the heading *and* one
below it. The formatter applies an edit that check never advertised. The LSP
quick-fix path applies the fix attached to the warning rather than calling
`rule.fix()`, so it inserts only the blank above, and the CLI and the editor
produce different documents from the same warning. The default rule set does not
mask this: MD041 and MD046 also fire on the input, but neither is fixable here,
so `rumdl fmt` makes both insertions.
` - deeper` is an indented code block, so the parser leaves `list_item` as
None. check() (:544) therefore also tests the line syntactically with
`starts_with_list_marker`, to keep the blank-below guard parse-stable - the
comment above it says "so the guard - and therefore the fix - stays idempotent".
fix_content() (:296) tested only `list_item`, saw a plain line, and inserted the
blank. The same term is added to fix_content() so both sides ask the same
question.
`rumdl fmt` output for that input changes from
text\n\n# Heading\n\n - deeper\n
to
text\n\n# Heading\n - deeper\n
Both parse identically - MD046 reports the indented code block either way - so
nothing about the rendered document changes. Only the unadvertised edit goes
away.
Measured over 69904 synthetic documents (every sequence of 1-4 lines over a
16-line alphabet, Standard flavour), comparing `rule.fix()` against
`apply_warning_fixes` over `rule.check()`: 5753 divergences before, 5166 after -
587 removed, 0 introduced. Documents needing a second `fix()` pass: 272 before,
272 after. MD032's divergence set over the same corpus is bit-identical. The
5166 that remain are three pre-existing classes this does not touch: 4368 end
with a blank line, 538 contain an HTML comment, 260 contain a blockquote.
Tests: two MD022 cases in tests/rules/md022_test.rs, one case in the CLI/LSP
consistency harness, and the MD022 entry in `get_test_content_for_rule` switched
to content that reaches the branch.
Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Ruben J. Jongejan <[email protected]>1 parent 6099a6c commit ef926b7
3 files changed
Lines changed: 42 additions & 6 deletions
File tree
- src/rules
- tests
- cli
- rules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
298 | | - | |
299 | | - | |
300 | | - | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
301 | 302 | | |
302 | 303 | | |
303 | 304 | | |
304 | 305 | | |
305 | 306 | | |
306 | | - | |
307 | | - | |
| 307 | + | |
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
263 | 263 | | |
264 | 264 | | |
265 | 265 | | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
266 | 285 | | |
267 | 286 | | |
268 | 287 | | |
| |||
283 | 302 | | |
284 | 303 | | |
285 | 304 | | |
286 | | - | |
| 305 | + | |
287 | 306 | | |
288 | 307 | | |
289 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
622 | 622 | | |
623 | 623 | | |
624 | 624 | | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
0 commit comments