Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cf-agent/files_editline.c
Original file line number Diff line number Diff line change
Expand Up @@ -1065,10 +1065,10 @@ static bool InsertMultipleLinesToRegion(EvalContext *ctx, Item **start, Item *be

if (a->location.before_after == EDIT_ORDER_BEFORE)
{
/* As region was already selected by SelectRegion() and we know
* what are the region boundaries (begin_ptr and end_ptr) there
* is no reason to iterate over whole file. */
for (ip = begin_ptr; ip != NULL; ip = ip->next)
/* Start at the top of the file so prev ends up as the line before
* the region. From begin_ptr prev stays NULL, and a NULL prev means
* prepend to the file. */
for (ip = *start; ip != NULL; ip = ip->next)
{
if (ip == begin_ptr)
{
Expand Down
9 changes: 4 additions & 5 deletions tests/acceptance/31_tickets/CFE-3987/1/test.cf
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ bundle agent test
string => "edit_line doesn't insert text immediately before a selected region if a location body only explicitly sets before_after => 'before'",
meta => { "CFE-3987" };

"test_soft_fail"
string => "any",
meta => { "CFE-3987" };

vars:
"seed_file" string => "$(this.promise_dirname)/before_test.xml.txt";
"test_file" string => "$(G.testfile)";
Expand All @@ -38,11 +34,14 @@ bundle agent test
}

bundle agent check
# @brief The selected region begins at the first line matching select_start,
# which is '<!-- General -->', so the line must be inserted immediately before
# it and not at the start of the file.
{
methods:
"Pass/FAIL"
usebundle => dcs_check_regcmp(
".*INSERT\sME\R\s+<!--\s=+\R\s+THIS MUST BE THE LAST FILTER IN THE DEFINED CHAIN.*",
".*\R\s+metadata-complete=\S+\RINSERT\sME\R\s+<!--\sGeneral\s-->.*",
readfile("$(test.test_file)"),
$(this.promise_filename),
"no"
Expand Down
Loading