diff --git a/.claude/skills/cfe-borrow/scripts/cfe-borrow.ps1 b/.claude/skills/cfe-borrow/scripts/cfe-borrow.ps1 index 89bbe6c6..7f36640a 100644 --- a/.claude/skills/cfe-borrow/scripts/cfe-borrow.ps1 +++ b/.claude/skills/cfe-borrow/scripts/cfe-borrow.ps1 @@ -476,9 +476,8 @@ function Borrow-Form { $formVersion = $srcFormEl.GetAttribute("version") if (-not $formVersion) { $formVersion = "2.17" } - # Find direct children: form properties, AutoCommandBar, ChildItems + # Find direct children: form properties and AutoCommandBar $srcAutoCmd = $null - $srcChildItems = $null $formProps = @() $reachedVisual = $false foreach ($fc in $srcFormEl.ChildNodes) { @@ -486,8 +485,8 @@ function Borrow-Form { if ($fc.LocalName -eq 'AutoCommandBar' -and -not $srcAutoCmd) { $reachedVisual = $true; $srcAutoCmd = $fc; continue } - if ($fc.LocalName -eq 'ChildItems' -and -not $srcChildItems) { - $reachedVisual = $true; $srcChildItems = $fc; continue + if ($fc.LocalName -eq 'ChildItems' -or $fc.LocalName -eq 'Events' -or $fc.LocalName -eq 'Attributes' -or $fc.LocalName -eq 'Commands' -or $fc.LocalName -eq 'Parameters') { + $reachedVisual = $true; continue } if (-not $reachedVisual) { # Form-level properties before AutoCommandBar (WindowOpeningMode, AutoFillCheck, etc.) @@ -498,31 +497,15 @@ function Borrow-Form { # Get OuterXml and strip redundant namespace redeclarations (they're on root
) $nsStripPattern = '\s+xmlns(?::\w+)?="[^"]*"' + # AutoCommandBar: copy only properties (Autofill etc.), strip ChildItems $autoCmdXml = "" if ($srcAutoCmd) { $autoCmdXml = $srcAutoCmd.OuterXml $autoCmdXml = [regex]::Replace($autoCmdXml, $nsStripPattern, '') - # Replace all CommandName values with 0 (base form buttons lose command refs) - $autoCmdXml = [regex]::Replace($autoCmdXml, '[^<]*', '0') + # Strip ChildItems from AutoCommandBar (buttons will appear from base form at runtime) + $autoCmdXml = [regex]::Replace($autoCmdXml, '(?s)\s*.*?', '') # Replace Autofill true → false $autoCmdXml = $autoCmdXml -replace 'true', 'false' - # Strip DataPath (references base form attributes not present in extension) - $autoCmdXml = [regex]::Replace($autoCmdXml, '\s*[^<]*', '') - # Strip element-level Events (base form event handlers not present in extension) - $autoCmdXml = [regex]::Replace($autoCmdXml, '(?s)\s*.*?', '') - } - - $childItemsXml = "" - if ($srcChildItems) { - $childItemsXml = $srcChildItems.OuterXml - $childItemsXml = [regex]::Replace($childItemsXml, $nsStripPattern, '') - # Replace all CommandName values with 0 in ChildItems too - $childItemsXml = [regex]::Replace($childItemsXml, '[^<]*', '0') - # Strip DataPath and element-level Events - $childItemsXml = [regex]::Replace($childItemsXml, '\s*[^<]*', '') - $childItemsXml = [regex]::Replace($childItemsXml, '(?s)\s*.*?', '') - } else { - $childItemsXml = "" } # Extract the opening tag from source text (preserves namespace declarations) @@ -538,7 +521,7 @@ function Borrow-Form { $formXmlSb.Append($formTag) | Out-Null $formXmlSb.Append("`r`n") | Out-Null - # Part 1: form properties + visual elements + # Part 1: form properties + AutoCommandBar (no ChildItems — they come from base form at runtime) foreach ($propXml in $formProps) { $propXml = [regex]::Replace($propXml, $nsStripPattern, '') $formXmlSb.Append("`t$propXml`r`n") | Out-Null @@ -547,12 +530,10 @@ function Borrow-Form { $formXmlSb.Append("`t$autoCmdXml") | Out-Null $formXmlSb.Append("`r`n") | Out-Null } - $formXmlSb.Append("`t$childItemsXml") | Out-Null - $formXmlSb.Append("`r`n") | Out-Null $formXmlSb.Append("`t") | Out-Null $formXmlSb.Append("`r`n") | Out-Null - # BaseForm: form properties + same visual elements, indented one more level + # BaseForm: same properties + AutoCommandBar (no ChildItems) $formXmlSb.Append("`t") | Out-Null $formXmlSb.Append("`r`n") | Out-Null @@ -570,13 +551,6 @@ function Borrow-Form { } } - $ciLines = $childItemsXml -split "`r?`n" - for ($li = 0; $li -lt $ciLines.Count; $li++) { - if ($li -eq 0) { $formXmlSb.Append("`t`t$($ciLines[$li])") | Out-Null } - else { $formXmlSb.Append("`t$($ciLines[$li])") | Out-Null } - $formXmlSb.Append("`r`n") | Out-Null - } - $formXmlSb.Append("`t`t") | Out-Null $formXmlSb.Append("`r`n") | Out-Null $formXmlSb.Append("`t") | Out-Null