Macros 2.0 - Optional scoped content + improved closing-tag autocomplete (#5117)

* feat(macros): Add optional scope detection and improved closing tag autocomplete

- Implement `isScopeOptional()` to detect when scoped content is optional based on macro argument requirements
- Filter optional scopes from autocomplete hints unless force-triggered (Ctrl+Space)
- Add "OPTIONAL" badge styling for optional scoped content in autocomplete UI
- Show multiple closing tag suggestions (innermost to outermost) with priority ordering
- Display nesting level information for nested optional scopes

* fix(autocomplete): show original macro details when typing closing tags

Add nameOffset=2 to MacroClosingTagAutoCompleteOption to skip {{ prefix for fuzzy highlighting. When typing closing tags ({{/macroName}}), detect and show the original macro's details instead of "no match" error by looking up the macro definition and creating a non-selectable context option with no argument highlighting.
This commit is contained in:
Wolfsblvt
2026-02-08 01:25:21 +01:00
committed by GitHub
parent 788ed3d323
commit 9f4449973b
5 changed files with 292 additions and 47 deletions
+22
View File
@@ -507,6 +507,28 @@
border-radius: 3px;
}
/* OPTIONAL badge for optional scoped content */
.macro-ac-optional-badge {
display: inline-block;
background: linear-gradient(135deg, #f0ad4e, #ec971f);
color: #000;
font-weight: bold;
font-size: 0.75em;
padding: 0.15em 0.5em;
border-radius: 3px;
text-transform: uppercase;
letter-spacing: 0.05em;
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
/* Smaller variant for use in autocomplete list items */
.macro-ac-optional-badge-small {
font-size: 0.65em;
padding: 0.1em 0.35em;
vertical-align: middle;
color: #f0ad4e;
}
/* Closing tag autocomplete option */
.autoComplete > .item.macro-closing-tag-item > .type {
color: var(--ac-color-matchedText, var(--SmartThemeBorderColor));