Repository navigation
fix(editor): recognize all bundled Monaco language associations - #23371
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review. 📝 WalkthroughWalkthroughThe changes add a script that extracts Monaco language IDs, extensions, and filenames into a JSON catalog. They add a test that compares the generated registrations with the catalog, and documentation for its source and matching rules. Renderer language detection now checks the catalog after existing filename and extension mappings and before its dotenv and plaintext fallbacks. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The filename-association change appears ready to merge after normal checks. Architecture SummaryArchitecture risk: 🟡 Medium · up to The change affects 3 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 5 files. (2 skipped: 2 unsupported.)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Adds a generated metadata file covering Monaco's built-in language filename/extension associations and consults it as a fallback in detectLanguage, so bundled languages (Bicep, WGSL, Pascal, reStructuredText, Cypher, F# …) no longer open as plaintext.
- Generated association metadata —
monaco-language-associations.jsonholds all 90 registrations from the installed Monaco 0.55.1 entry point, produced by a generator that parses*.contribution.jssyntax trees without executing grammars; a drift test forces regeneration on upgrade. - Filename detection fallback —
monaco-filename-language.tsbuilds lowercase filename/extension maps and resolves exact filenames before the longest extension, matching Monaco's own precedence and last-registration-wins rule (.pp→ ruby). detectLanguageintegration — the fallback sits after Orca'sEXT_TO_LANGUAGEand before the dotenv branch, preserving custom languages and.env.*handling;FILENAME_TO_LANGUAGE[filename]becameObject.hasOwn(...)so prototype names (constructor,__proto__) no longer leak theObjectprototype.- Tests and docs — renderer tests pin all unambiguous upstream associations,
.ppprecedence, Windows/UNC/remote paths, and preserved Orca behavior.
Beyond reading the diff I verified the load-bearing claims: the direct .contribution.js imports of editor.main.js contain exactly 90 registerLanguage/languages.register({ call sites and the JSON has 90 entries, so the generator is complete relative to the entry point; and languagesAssociations.js#getAssociationByPath confirms Monaco resolves exact filename before the longest extension with later registrations winning, which this implementation mirrors. The generator drift test, monaco-filename-language tests, language-detect tests, tc:web, oxlint on the touched files, and oxfmt --check on the JSON all pass.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Verified the unchanged head e2fc10b: all 107 focused tests pass again, plus a targeted check reproducing both XAML cases from #16530 and confirming the scope of related requests. The earlier hidden Electron validation on this exact head showed Bicep changing from plaintext to real colored tokens; before/after screenshots are attached in the description. CI static analysis, typecheck, and Linux/Windows packaging have passed; remaining unit-test shards are still running. Reviewed the open language PRs/issues before closing duplicates. Only #16530 / #16396 are fully covered. Custom grammars (CUDA, VHDL, Nix, OCaml, Godot, VCL, Quarto, MATLAB/LaTeX), JSP improvements, mobile highlighting, and user grammar loading remain separate work. Community credits are now in the description. |

ELI5
Files such as Bicep, WGSL, Pascal, and reStructuredText opened as plain text even though Orca already bundled their highlighting. Recognize every filename association shipped by Monaco so these no longer need one-language PRs.
What Changed
Added a small generated metadata file covering all 90 built-in registrations in Monaco 0.55.1, including the 81 with filenames or extensions. Filename detection keeps Orca's existing choices first, then uses Monaco's exact filenames and longest matching extensions. Ambiguous extensions follow upstream registration order (
.ppselects Ruby). Prototype property names such asconstructorsafely remain plain text.The generator reads the installed package's registration syntax without executing grammars. A drift test requires regeneration when Monaco changes. Cloned
microsoft/monaco-editoratv0.55.1(516f350bdaf7a82f6731bd128a9ec86a6e5fa47d) to inspect the authoritative registrations and lazy loading. Regeneration instructions are indocs/reference/monaco-language-associations.md.Why
Orca already imports Monaco's full language entry point; its separate handwritten filename table was the gap. Generated metadata avoids adding more one-off rows and avoids importing the full editor during session restoration. Grammars still load on demand. Existing custom languages, previews, and
.mdx→ Markdown behavior are preserved. Languages with no filename association cannot be inferred from paths; this does not add language servers or change mobile's separate grammar set.Linked Issue
Follow-up to #20928, now merged; related to #13835.
Visual Proof
Real Orca editor in a hidden Electron instance on macOS, same Bicep file in a folder workspace. Before uses the base branch detector; after uses this branch, including session restoration. The file was opened through the file tree. Verified the model language changed from
plaintexttobicepand inspected rendered token colors.Testing
107 tests passed across filename detection, all unambiguous upstream associations, Solidity registration, and generated metadata drift. Coverage includes Windows/UNC paths, remote-style paths, folder names containing extensions, custom overrides, unknown names, and
.ppprecedence.pnpm tc:webandpnpm run check:code-quality:changedpassed. Hidden Electron dev build and CDP rendered check passed. Native Windows/Linux and a live SSH host were not exercised; detection is renderer-only and host-independent. Full build and broader test suite left to CI.Review
Self-reviewed registration extraction, precedence, lazy loading, and path handling.
Agent skill upstream boundary
Notes
No IPC, remote protocol, filesystem access, new dependencies, or grammar imports are added to the renderer. The generated JSON is approximately 8 KB before bundling. Existing Monaco grammar behavior still applies.
Checklist
Community credit and related work
Thanks to @anajuliabit for the Solidity fix in #20928 that prompted this broader solution; @psh4607 for the XAML mapping and regression cases in #16530; and @smaucy for reporting the XAML gap in #16396. This PR covers both XAML cases, including uppercase Windows paths, through Monaco's own XML associations.
Also thanks to @randyc-kh for #11215 and @albarracin-jorge for #13236: this change covers
.tfvarsand.hbs/.handlebars, respectively. Those items remain open because justfiles and Glimmer.gjs/.gtsrequire additional work. Thanks to @el-analista for #19968:.jlnow selects Monaco's built-in Julia grammar, but richer Julia tokenization is a separate request and remains open.