Commit ded966a
fix(cmdlet): add blank line before summary when match is near file end
Update-LinesInFile's chronological output is supposed to look like:
==> path <==
1- ctx
2- ctx
: deleted
3: inserted
4- post-ctx
5- post-ctx
<-- blank separator
Updated path: ...
The blank-separator emission was guarded by
\`afterContextCounter == 0\` inside the post-context loop. When the
match landed near the end of the file (e.g. range 3-4 in a 5-line
file) the loop ran out of file before the counter could decrement
twice, so the blank was never emitted and the summary line landed
directly under the last context row with no visual gap. The
existing BlankLineSeparation Pester test had been failing on this
case for that reason.
Track \`endedWithBlank\` at every WriteObject("") site (3 places
inside ReplaceLineRangeWithDisplay). After the inner using-block
ends, if the header was printed but the last emission was a context
line, emit one trailing blank. Existing blank emissions stay where
they are; the new tail-emit only fires in the file-runs-out-mid-
post-context branch that previously had no separator.
Verified with two cases against the rebuilt DLL:
* 5-line file + range 3-4 (the failing test's shape): now emits a
blank between the last context row "5- Line 5" and the summary,
so the test's \`lines[$lastContextIndex + 1] | Should -Match
'^\s*$'\` check passes.
* 8-line file + range 3-4 (counter reaches 0 normally): output is
unchanged — single blank between context block and summary.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 3d9314a commit ded966a
1 file changed
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
309 | 319 | | |
310 | 320 | | |
311 | 321 | | |
| |||
391 | 401 | | |
392 | 402 | | |
393 | 403 | | |
| 404 | + | |
394 | 405 | | |
395 | 406 | | |
396 | 407 | | |
| |||
417 | 428 | | |
418 | 429 | | |
419 | 430 | | |
| 431 | + | |
420 | 432 | | |
421 | 433 | | |
422 | 434 | | |
| |||
443 | 455 | | |
444 | 456 | | |
445 | 457 | | |
| 458 | + | |
446 | 459 | | |
447 | 460 | | |
448 | 461 | | |
| |||
479 | 492 | | |
480 | 493 | | |
481 | 494 | | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
482 | 507 | | |
483 | 508 | | |
484 | 509 | | |
| |||
0 commit comments