Files
pbakaus_impeccable/tests
Paul BakausandClaude Opus 4.7 99cccc2f9b fix(live-inject): preserve indentation on remove, no orphan blank line
The insert path puts the block's opener line right after the anchor's
indent (e.g. six spaces plus </body>), which transfers the indent
onto the opener line and leaves the anchor unindented in the injected
file. The remove path consumed the block's trailing newline but left
the pre-block indent behind, producing two bugs in one:

  Before insert:  `      </body>`
  After remove:   `      \n</body>`  (orphan indent + unindented anchor)

Fix: capture `([ \t]*)` immediately before each marker and replace the
whole block (including its trailing newline and any trailing spaces on
the ender line) with just the captured indent. The indent now hands
itself back to the anchor line that follows — the file round-trips
byte-for-byte.

New tests/live-inject.test.mjs with four round-trip cases:
- HTML file with indented </body>
- JSX layout with indented </body> (EAC shape)
- Multi-file batch
- Column-0 </body> (no indent — already worked; regression baseline)

All four pass after the fix. Full suite clean via `bun run test`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-22 01:09:49 -07:00
..