mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-26 06:54:38 +03:00
Fix XML formatting in batch insert and after clear operations
Two bugs caused tag concatenation (e.g. `</item><item`): - Insert-BeforeElement: place new node before trailing whitespace, not before the preceding newline - Get-ContainerChildIndent: check for Element children instead of HasChildNodes to correctly detect empty containers after clear-* Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -961,7 +961,7 @@ function Insert-BeforeElement($container, $newNode, $refNode, $childIndent) {
|
||||
$trailing = $container.LastChild
|
||||
if ($trailing -and ($trailing.NodeType -eq 'Whitespace' -or $trailing.NodeType -eq 'SignificantWhitespace')) {
|
||||
$container.InsertBefore($ws, $trailing) | Out-Null
|
||||
$container.InsertBefore($newNode, $ws) | Out-Null
|
||||
$container.InsertBefore($newNode, $trailing) | Out-Null
|
||||
} else {
|
||||
$container.AppendChild($ws) | Out-Null
|
||||
$container.AppendChild($newNode) | Out-Null
|
||||
@@ -1223,12 +1223,16 @@ function Get-DataSetName($dsNode) {
|
||||
}
|
||||
|
||||
function Get-ContainerChildIndent($container) {
|
||||
$ci = Get-ChildIndent $container
|
||||
if (-not $container.HasChildNodes) {
|
||||
$settingsIndent = Get-ChildIndent $container.ParentNode
|
||||
$ci = $settingsIndent + "`t"
|
||||
$hasElements = $false
|
||||
foreach ($ch in $container.ChildNodes) {
|
||||
if ($ch.NodeType -eq 'Element') { $hasElements = $true; break }
|
||||
}
|
||||
if ($hasElements) {
|
||||
return Get-ChildIndent $container
|
||||
} else {
|
||||
$parentIndent = Get-ChildIndent $container.ParentNode
|
||||
return $parentIndent + "`t"
|
||||
}
|
||||
return $ci
|
||||
}
|
||||
|
||||
# --- 6. Load XML ---
|
||||
|
||||
Reference in New Issue
Block a user