Skip to content

CFE-3988: Fixed insert_lines ignoring include_end_delimiter when locating the region - #6265

Open
nickanderson wants to merge 1 commit into
cfengine:masterfrom
nickanderson:CFE-3988/master
Open

CFE-3988: Fixed insert_lines ignoring include_end_delimiter when locating the region#6265
nickanderson wants to merge 1 commit into
cfengine:masterfrom
nickanderson:CFE-3988/master

Conversation

@nickanderson

Copy link
Copy Markdown
Member

SelectRegion() returns the delimiter lines themselves, and the insertion path treats the region as the half-open range [begin_ptr, end_ptr) — so the end delimiter was never inside the region it searched. Inserting after the last line of a region built with include_end_delimiter => "true" landed above the end delimiter instead of below it.

DeletePromisedLinesMatching() already translates include_end_delimiter into that bound; insertion now does the same.

The bound only moves when include_end_delimiter is set, and that attribute previously had no effect at all on insert_lines — all ~90 existing tests using it are under 07_delete_lines, none under 06_insert_lines. So nothing could have depended on the old behavior.

Tests

  • 31_tickets/CFE-3988/1 — the ticket's reproducer, no longer test_soft_fail
  • 31_tickets/CFE-3988/2 — new, pins the unchanged include_end_delimiter => "false" default

Verification (local starter_pack VM)

  • Full acceptance suite: 1648 passed, 0 regressions, soft failures 44 → 43
  • Unsafe tests (10_files, incl. 15_immutable_edit_line): 24/24
  • Unit tests: 70/70
  • Negative control: with the fix reverted and rebuilt, case 1 fails and case 2 still passes

15_control/01_common/classic_evaluation_custom_promise_types.cf fails, but it fails identically with the fix reverted — its fixture top_down/dummy_promise_type.py is absent from the repo. Pre-existing and unrelated.

Ticket: https://northerntech.atlassian.net/browse/CFE-3988

Backports to 3.27.x and 3.24.x to follow, matching CFE-3987.

…egion

SelectRegion() hands back the delimiter lines themselves, and the
insertion path treats the region as the half-open range
[begin_ptr, end_ptr), so the end delimiter was never part of the region
it searched. Promising a line after the last line of a region built with
include_end_delimiter => "true" therefore inserted above the end
delimiter rather than below it.

Line deletion already translates include_end_delimiter into that bound
in DeletePromisedLinesMatching(); insertion now does the same. The bound
only moves when include_end_delimiter is set, and that attribute
previously had no effect at all on insert_lines, so the default of
inserting before an excluded end delimiter is unchanged. Acceptance test
31_tickets/CFE-3988/2 covers that default and 31_tickets/CFE-3988/1 is
no longer a soft failure.

Ticket: CFE-3988
Changelog: Title
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant