Skip to content
Open
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
15 changes: 14 additions & 1 deletion tests/acceptance/plucked.sub.cf
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,18 @@ bundle edit_line manage_variable_values_ini(tab, sectionName)
{
vars:
"index" slist => getindices("$(tab)[$(sectionName)]");
"_escaped_section" string => escape("$(sectionName)");

classes:
"section_$(sectionName)_exists"
expression => regline("^\[$(_escaped_section)\]", "$(edit.filename)"),
if => fileexists("$(edit.filename)"),
comment => "Check if the section header already exists in the file";

delete_lines:
".*"
select_region => INI_section(escape("$(sectionName)")),
if => canonify("section_$(sectionName)_exists"),
comment => "Remove all entries in the region so there are no extra entries";

insert_lines:
Expand All @@ -752,7 +760,12 @@ bundle edit_line manage_variable_values_ini(tab, sectionName)
comment => "Insert lines";

"$(index)=$($(tab)[$(sectionName)][$(index)])"
select_region => INI_section(escape("$(sectionName)"));
select_region => INI_section(escape("$(sectionName)")),
if => canonify("section_$(sectionName)_exists");

"$(index)=$($(tab)[$(sectionName)][$(index)])"
location => after("^\[$(_escaped_section)\]"),
if => not(canonify("section_$(sectionName)_exists"));
}

bundle edit_line set_variable_values_ini(tab, sectionName)
Expand Down
Loading