[Bug]: proto files have no syntax highlighting (wrong Monaco language id)
Operating system
macOS
Orca version
v1.4.145-rc.3
Details
Details
Short summary:
Opening a .proto (Protocol Buffers) file in the editor shows flat, uncolored text. Monaco ships a Protocol Buffers grammar, so this is a wiring bug rather than a missing language.
What happened?
src/renderer/src/lib/language-detect.ts maps .proto to the language id 'protobuf'. Monaco registers Protocol Buffers under the id 'proto' — 'protobuf' is only an alias:
// monaco-editor/esm/vs/basic-languages/protobuf/protobuf.contribution.js
registerLanguage({
id: "proto",
extensions: [".proto"],
aliases: ["protobuf", "Protocol Buffers"],
loader: () => import('./protobuf.js')
});
Monaco matches ids and never resolves aliases, and it degrades silently rather than erroring, so every surface that passes the id explicitly loses highlighting:
- File editor and diff viewer.
@monaco-editor/reactcallsmonaco.editor.createModel(value, language, uri). With an explicit language, Monaco usescreateById(), which falls back to plaintext when the id is unregistered. It only guesses from the file path when no language is passed — and Orca always passes one (EditorContentderives it viadetectLanguage,MonacoEditorforwards it aslanguage={...}). - PR/issue review comment code excerpts.
MonacoCodeExcerptcallsmonaco.editor.colorize(code, language), which failsisRegisteredLanguageIdand returns uncolored output.
How can we reproduce it?
- Open any repo containing a
.protofile, or createapi/v1/service.protowith asyntax = "proto3";line, amessage, and aserviceblock. - Open it from the file explorer.
- The file renders with no syntax coloring —
syntax,message,service,rpcare the same color as everything else. A.tsfile in the same repo colors normally.
Verification:
Asking Monaco directly what each id resolves to:
createModel(sample, 'protobuf', Uri.file('x.proto')).getLanguageId() -> "plaintext"
createModel(sample, 'proto', Uri.file('x.proto')).getLanguageId() -> "proto"
createModel(sample, undefined, Uri.file('x.proto')).getLanguageId() -> "proto"
And for the excerpt path, comparing distinct mtk* token classes in the colorized HTML:
| language id passed | registered? | token classes produced |
|---|---|---|
protobuf (current) |
no | mtk1 — uncolored |
proto (fix) |
yes | mtk1, mtk6, mtk7, mtk20, mtk22 |
Anything else that might help:
- Not platform-specific. The mapping table is plain renderer code with no platform branches, so macOS, Linux, and Windows are affected identically, and it behaves the same for local and SSH worktrees.
- No git-provider-specific behavior; the excerpt components are shared across providers.
- The fix is a one-line change in the extension map (
'.proto': 'proto'). Monaco lazy-loads the tokenizer on first use, so no bundling or worker change is needed.