Repository navigation
color fenced divs by nesting depth - #18467
Conversation
The rainbow fenced div highlighting assigned colors from a counter that only advanced on closing fences, so nested divs shared their parent's color and unrelated fences drifted through the palette. Color fences by nesting depth instead, mirroring the rainbow parentheses logic: nested divs get new colors, siblings at the same depth share one, and open/close pairs always match. Addresses #18464
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
RStudio E2E - all platformsAll tests passed!
View / download the full reportView report online -- opens in the browser, no download needed. Available for 14 days. Download playwright-report.zip -- extract and open
All platforms - commit |
Code review findingsActionable items from an automated multi-agent review. The core change is correct: the open/close Findings 1 and 2 were verified by running the real Ace Important
Suggestions
|
- simplify the fenced div onMatch depth bookkeeping and fix the stale 'opening fenced div' comment - restore rainbow_fenced_divs with clearPref() in the e2e tests so later tests see the schema default (true) again - derive fence rows from the test content and assert full token type/value pairs in the nested fenced div e2e test - add a standalone markdown highlight test page covering nesting depth, the unmatched-close clamp, color wrap past seven levels, indented (non-)fences, and rainbow-off
|
Thanks -- applied most of this in 6b5fb57. 1 (stale colors on edit): The mechanism is real, but it's already tracked and fixed: #18472 covers exactly this staleness, and PR #18473 (with rstudio/rstudio-ace#13) makes the per-row context part of the background tokenizer's invalidation key -- which fixes the same issue for rainbow parens too. Once that lands, the on-screen invariant holds; I'd rather merge that alongside this PR than soften the NEWS wording. 2 (indented fences): Checked against pandoc (3.10.1, plus quarto's bundled pandoc): the So coloring 3, 9: Added 4: Both tests now 5-8: Applied: collapsed the depth/color bookkeeping, fixed the stale comment, derived the fence rows from the test content, and the e2e loop now asserts full token type/value pairs. 10: Left as-is -- pre-existing dead API shared with |
Summary
The rainbow fenced div highlighting in the source editor assigned colors from a counter that only advanced on closing fences, so colors did not follow the document's nesting structure: nested divs shared their parent's color, and sibling divs at the same level received different colors.
This regressed in #14744, which replaced the original color stack (it abused the Ace tokenizer stack, breaking editor tools) with a simple counter that tracked the wrong thing.
Fences are now colored by nesting depth, mirroring the rainbow parentheses logic in
rainbow_paren_highlight_rules.js: a nested div gets a different color than its parent, siblings at the same depth share a color, and opening/closing fences of the same div always match. This also matches Positron's behavior for nested fenced divs.Testing
syntax-highlighting.test.tssuite passes locally (desktop-dev).Fixes #18464.