CFE-2663: Select empty region at end of file when select_end_match_eof is set#6208
Open
nickanderson wants to merge 2 commits into
Open
CFE-2663: Select empty region at end of file when select_end_match_eof is set#6208nickanderson wants to merge 2 commits into
nickanderson wants to merge 2 commits into
Conversation
An insert_lines promise using select_region with select_end_match_eof cannot select the region of the final section when that section header is the last line of the file. The region is empty and sits at the end of the file, SelectRegion() rejects it, and the insertion fails with "could not select an edit region". This test fails today and will pass once SelectRegion() honors select_end_match_eof for an empty region at end of file. Ticket: CFE-2663 Changelog: None Signed-off-by: Nick Anderson <nick@cmdln.org>
When select_region matched a start delimiter on the last line of the file and include_start_delimiter was false, SelectRegion() rejected the region as an "empty region at the end of file" and the edit failed with "could not select an edit region". This happened even when select_end_match_eof was true, which is meant to let the region extend to the end of the file. Now the empty region at end of file is accepted when select_end_match_eof is set, so a trailing section (its header being the last line of the file) can still be populated by insert_lines and similar promises. Ticket: CFE-2663 Changelog: Title Signed-off-by: Nick Anderson <nick@cmdln.org>
Member
Author
|
@cf-bottom jenkins please |
|
Alright, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/14084/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-14084/ |
Member
Author
|
@cf-bottom jenkins please |
olehermanse
approved these changes
Jul 2, 2026
|
Sure, I triggered a build: Jenkins: https://ci.cfengine.com/job/pr-pipeline/14093/ Packages: http://buildcache.cfengine.com/packages/testing-pr/jenkins-pr-pipeline-14093/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an
insert_lines(or otheredit_line) promise usesselect_regionwithselect_end_match_eof => "true", and theselect_startdelimiter matches the last line of the file,SelectRegion()rejects the (empty) region at EOF and the edit fails with "could not select an edit region". This makes the final section of an INI-style file impossible to populate once it is empty, which is exactly whatset_variable_values_ini()/manage_variable_values_ini()hit in the wild.This PR is structured for TDD:
31_tickets/CFE-2663/) that inserts a key into an empty trailing section. It fails today.SelectRegion()honorselect_end_match_eoffor an empty region at end of file, turning the test green.Ticket: https://northerntech.atlassian.net/browse/CFE-2663