fix(light-touch): preserve original blank line counts during merge#11
Conversation
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
|
@claude review |
|
Claude finished @peterjthomson's task in 1m 28s —— View job Code Review
|
The mergeWithOriginal function was using blank lines from regenerated markdown instead of preserving original blank lines. This caused intentional double blank lines to collapse to single blank lines whenever any edit was made elsewhere in the file. Changes: - When NO new content in a gap: preserve original gap lines exactly (fixes the double-blank collapse issue) - When new content IS inserted: use Muya's spacing since the document structure has changed (preserves proper spacing around new content) - Apply same logic to tail handling after last matched line This fixes unwanted diffs for files with intentional multiple blank lines used for visual separation, while still allowing Muya to determine appropriate spacing when new content is added.
290bb1c to
8a9b000
Compare

Problem
The Light Touch mode's
mergeWithOriginalfunction was causing unwanted diffs for files with intentional double (or multiple) blank lines.When editing a file like:
# Heading Paragraph (note: 2 blank lines above)Any edit elsewhere in the file would collapse the double blank lines to a single blank line on save.
Root Cause
The merge algorithm:
# Heading,Paragraph)Solution
Updated
mergeWithOriginalto:Testing
Documentation
Updated
docs/todo/save-light-touch.mdto mark this issue as fixed.