mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-08-15 07:49:01 +03:00
fix(cfe-borrow): паритет портов при дозаписи реквизитов в оболочку
PS вставлял лишнюю строку с табуляцией перед первым <Attribute>, когда дозаписывал реквизиты в заимствованную оболочку с самозакрытым <ChildObjects/>: элемент раскрывался пробельным узлом в DOM, а последующая текстовая вставка добавляла отступ ещё раз. У Конфигуратора в таких файлах пустых строк нет ни одной, py-порт делал правильно. PS сведён к тому же текстовому раскрытию, что и py. Расхождение портов на Document.ВнутреннееПотребление (-BorrowMainAttribute Form) закрыто: выходы отличаются только свежесгенерированными uuid. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
656160407a
commit
8c915df0d9
@@ -1,4 +1,4 @@
|
|||||||
# cfe-borrow v1.26 — Borrow objects from configuration into extension (CFE)
|
# cfe-borrow v1.27 — Borrow objects from configuration into extension (CFE)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
param(
|
param(
|
||||||
[Parameter(Mandatory)][string]$ExtensionPath,
|
[Parameter(Mandatory)][string]$ExtensionPath,
|
||||||
@@ -1571,14 +1571,6 @@ function Merge-AttributesIntoObject {
|
|||||||
$added = 0
|
$added = 0
|
||||||
foreach ($attr in $attrsToAdd) {
|
foreach ($attr in $attrsToAdd) {
|
||||||
if ($existingNames.ContainsKey($attr.Name)) { continue }
|
if ($existingNames.ContainsKey($attr.Name)) { continue }
|
||||||
$attrXml = Build-AdoptedAttributeXml $attr.Name $attr.Uuid $attr.TypeXml "`t`t`t"
|
|
||||||
|
|
||||||
# Expand self-closing ChildObjects if needed
|
|
||||||
if (-not $childObjs.HasChildNodes -or $childObjs.IsEmpty) {
|
|
||||||
$closeWs = $objDoc.CreateWhitespace("`r`n`t`t")
|
|
||||||
$childObjs.AppendChild($closeWs) | Out-Null
|
|
||||||
}
|
|
||||||
|
|
||||||
$added++
|
$added++
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1605,8 +1597,14 @@ function Merge-AttributesIntoObject {
|
|||||||
if ($text3.Length -gt 0 -and $text3[0] -eq [char]0xFEFF) { $text3 = $text3.Substring(1) }
|
if ($text3.Length -gt 0 -and $text3[0] -eq [char]0xFEFF) { $text3 = $text3.Substring(1) }
|
||||||
$text3 = $text3.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
$text3 = $text3.Replace('encoding="utf-8"', 'encoding="UTF-8"')
|
||||||
|
|
||||||
# Insert attributes before </ChildObjects>
|
# Insert attributes — handle both <ChildObjects/> and <ChildObjects>...</ChildObjects>.
|
||||||
$text3 = $text3 -replace '</ChildObjects>', "${allAttrXml}`r`n`t`t</ChildObjects>"
|
# Самозакрытый элемент раскрывается здесь же, а не пробельным узлом в DOM: тот давал
|
||||||
|
# лишнюю строку с табуляцией перед первым <Attribute> (у Конфигуратора пустых строк нет).
|
||||||
|
if ($text3 -match '<ChildObjects\s*/>') {
|
||||||
|
$text3 = [regex]::Replace($text3, '<ChildObjects\s*/>', "<ChildObjects>${allAttrXml}`r`n`t`t</ChildObjects>")
|
||||||
|
} else {
|
||||||
|
$text3 = $text3.Replace('</ChildObjects>', "${allAttrXml}`r`n`t`t</ChildObjects>")
|
||||||
|
}
|
||||||
|
|
||||||
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Внутри
|
# Пустой элемент: XmlWriter отдаёт `<a />`, Конфигуратор пишет `<a/>`. Внутри
|
||||||
# CDATA/комментария ` />` может быть содержимым (там `>` не экранируется),
|
# CDATA/комментария ` />` может быть содержимым (там `>` не экранируется),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
# cfe-borrow v1.26 — Borrow objects from configuration into extension (CFE)
|
# cfe-borrow v1.27 — Borrow objects from configuration into extension (CFE)
|
||||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
|||||||
Reference in New Issue
Block a user