Repository navigation
fix(editor): highlight Solidity files - #20928
Conversation
Map .sol to Monaco's built-in 'sol' language id. The grammar already ships with monaco-editor; only the extension lookup was missing, so .sol fell through to plaintext. Closes stablyai#13835
|
Warning Review limit reachedNext included review available in 2 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
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 (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe language detector now maps Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The change enables Solidity highlighting through the existing editor path without introducing an established production risk. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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
- Solidity extension mapping — adds
'.sol': 'sol'toEXT_TO_LANGUAGEinsrc/renderer/src/lib/language-detect.ts, with a comment explaining thatsolis the registered id andsolidityis only an alias. - Unit coverage — adds a
.solcase (including a case-insensitive Windows path) tolanguage-detect.test.ts. - Registry pin — new
solidity-language-id-registration.test.tsreads the installedmonaco-editorSolidity contribution and asserts the table id matches the id upstream actually registers.
I verified the mapping is correct for the installed [email protected]: both esm/vs/basic-languages/solidity/solidity.contribution.js and the min build register id: "sol" with .sol, and monaco-setup.ts's import * as monaco from 'monaco-editor' resolves to editor.main.js, which imports that contribution — so the id is genuinely registered at runtime. The two tests pass (17 total), check:code-quality:changed reports 0 new findings, and oxlint is clean on all three files. The .sol row has no side effects on preview affordances (canPreviewLanguage only matches html).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Merged
maininto the PR branch — new head2485d83mergesmain(fc69ec1). The merge resolves thelanguage-detect.test.tsoverlap by retaining the.solcase alongsidemain's newer Apex/Twig cases. The net PR-authored delta is unchanged:git diff <main-tip> HEADstill reports exactly the same 3 files / 27 insertions.
The substantive change ('.sol': 'sol' in EXT_TO_LANGUAGE plus the registry-pin test) was reviewed at ee4f12f and still stands. I re-ran both focused test files at the merge head: 73 passed.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
.solfiles showed up as grey plain text. Monaco already knows how to colour Solidity; nobody had told Orca which id to ask for. One row in a lookup table.What Changed
src/renderer/src/lib/language-detect.ts: added'.sol': 'sol'toEXT_TO_LANGUAGE.Plus two tests: a case in
language-detect.test.ts, andsolidity-language-id-registration.test.ts, which pins the mapped id against the idmonaco-editoractually registers.Why
detectLanguageresolves through a hand-maintained extension table and falls back toplaintext, never consulting Monaco's own registry..solwas not in the table, so the Solidity grammar that ships insidemonaco-editorloaded into the registry and was never requested. Same shape as #5414 (SystemVerilog/Verilog), which was fixed by adding its rows —.sv,.svh,.v,.vhare all in the table today.The id is
sol, notsolidity. Upstream registers:Mapping the alias fails silently — an unknown id renders as plain text with no error, which looks exactly like the bug being fixed. The repo already hit this with
.proto(idproto, aliasprotobuf), and that test name says so explicitly. The extra test file exists because a comment cannot fail CI: it reads the id out of the installedsolidity.contribution.js, so an upstream rename breaks the build instead of the editor. Both tests were mutation-checked — swappingsolforsolidityfails both.Scope note: the mobile file viewer has its own map (
mobile/src/session/mobile-file-language.ts) backed by lowlight'scommonset, which carries no Solidity grammar. Out of scope here, same as Verilog.Linked Issue
Fixes #13835
Visual Proof
Real
monaco-editor0.55.1,vs-dark, same source file, language id the only variable.plaintext)sol)Testing
macOS (Apple Silicon). Not tested on Linux/Windows/SSH — the change is a platform-independent table entry, and the case-insensitive Windows-path assertion is covered in the unit test.
Mutation check, to show the tests are not vacuous: