Skip to content

fix(editor): highlight Solidity files - #20928

Merged
nwparker merged 2 commits into
stablyai:mainfrom
anajuliabit:fix/solidity-language-detection
Sep 27, 2026
Merged

nwparker merged 2 commits into
stablyai:mainfrom
anajuliabit:fix/solidity-language-detection

Conversation

@anajuliabit

Copy link
Copy Markdown
Contributor

ELI5

.sol files 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' to EXT_TO_LANGUAGE.

Plus two tests: a case in language-detect.test.ts, and solidity-language-id-registration.test.ts, which pins the mapped id against the id monaco-editor actually registers.

Why

detectLanguage resolves through a hand-maintained extension table and falls back to plaintext, never consulting Monaco's own registry. .sol was not in the table, so the Solidity grammar that ships inside monaco-editor loaded into the registry and was never requested. Same shape as #5414 (SystemVerilog/Verilog), which was fixed by adding its rows — .sv, .svh, .v, .vh are all in the table today.

The id is sol, not solidity. Upstream registers:

registerLanguage({ id: 'sol', extensions: ['.sol'], aliases: ['sol', 'solidity', 'Solidity'], ... })

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 (id proto, alias protobuf), 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 installed solidity.contribution.js, so an upstream rename breaks the build instead of the editor. Both tests were mutation-checked — swapping sol for solidity fails both.

Scope note: the mobile file viewer has its own map (mobile/src/session/mobile-file-language.ts) backed by lowlight's common set, which carries no Solidity grammar. Out of scope here, same as Verilog.

Linked Issue

Fixes #13835

Visual Proof

Real monaco-editor 0.55.1, vs-dark, same source file, language id the only variable.

Before (plaintext) After (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.

pnpm test src/renderer/src/lib          → 559 files, 5427 passed, 1 skipped
pnpm tc                                 → exit 0
pnpm run check:code-quality:changed     → 0 new findings across 3 files
oxlint / oxfmt                          → clean

Mutation check, to show the tests are not vacuous:

'.sol': 'sol'       → 17 passed
'.sol': 'solidity'  → 2 failed (both new tests)
.sol removed        → 2 failed
  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

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
@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 2 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 9b03b92c-f36b-490d-a530-711d4a61ed28

📥 Commits

Reviewing files that changed from the base of the PR and between ee4f12f and 2485d83.

📒 Files selected for processing (2)
  • src/renderer/src/lib/language-detect.test.ts
  • src/renderer/src/lib/language-detect.ts

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 2551de9c-b99e-4388-bdc1-c31b7dc309de

📥 Commits

Reviewing files that changed from the base of the PR and between ea7902c and ee4f12f.

📒 Files selected for processing (3)
  • src/renderer/src/lib/language-detect.test.ts
  • src/renderer/src/lib/language-detect.ts
  • src/renderer/src/lib/solidity-language-id-registration.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The language detector now maps .sol files to Monaco’s sol language id. Tests cover POSIX paths, Windows-style paths, and uppercase extensions. A separate test reads the installed Monaco Solidity contribution and verifies that the detected id matches its registered id.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to ee4f1

The change enables Solidity highlighting through the existing editor path without introducing an established production risk.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: enabling Solidity syntax highlighting in the editor.
Description check ✅ Passed The description covers the change, reason, linked issue, visual proof, testing, platform coverage, and scope. It omits the AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist se…
Linked Issues check ✅ Passed The change meets issue #13835. language-detect.ts maps .sol to Monaco language ID sol, so Solidity files no longer use plaintext. Tests cover POSIX and Windows paths, uppercase extensions, and…
Out of Scope Changes check ✅ Passed The changes stay within the linked issue scope. They add the .sol mapping and tests that verify language detection and the Monaco registration. No mobile file-viewing changes or unrelated product ch…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 3…

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Solidity extension mapping — adds '.sol': 'sol' to EXT_TO_LANGUAGE in src/renderer/src/lib/language-detect.ts, with a comment explaining that sol is the registered id and solidity is only an alias.
  • Unit coverage — adds a .sol case (including a case-insensitive Windows path) to language-detect.test.ts.
  • Registry pin — new solidity-language-id-registration.test.ts reads the installed monaco-editor Solidity 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).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 90bae01 into stablyai:main Sep 27, 2026
1 check passed

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Merged main into the PR branch — new head 2485d83 merges main (fc69ec1). The merge resolves the language-detect.test.ts overlap by retaining the .sol case alongside main's newer Apex/Twig cases. The net PR-authored delta is unchanged: git diff <main-tip> HEAD still 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.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Support syntax highlighting for Solidity (.sol) files

2 participants