Repository navigation
Description
Since processed profile json version 64 its possible to include source code of various languages in the profile json. It would be far nicer if this source code was able to be syntax highlighted, at least for all languages supported by CodeMirror.
The current syntax highlighting switch hardcodes js, rust, and cpp:
profiler/src/components/shared/SourceView-codemirror.ts
Lines 49 to 79 in f3c1c76
| function _languageExtForPath(path: string | null): LanguageSupport | [] { | |
| if (path === null) { | |
| return []; | |
| } | |
| if (path.endsWith('.rs')) { | |
| return rust(); | |
| } | |
| if (path.endsWith('.tsx')) { | |
| return javascript({ typescript: true, jsx: true }); | |
| } | |
| if (path.endsWith('.ts')) { | |
| return javascript({ typescript: true }); | |
| } | |
| if (path.endsWith('.jsx')) { | |
| return javascript({ jsx: true }); | |
| } | |
| if (path.endsWith('.js') || path.endsWith('.jsm') || path.endsWith('.mjs')) { | |
| return javascript(); | |
| } | |
| if ( | |
| path.endsWith('.c') || | |
| path.endsWith('.cc') || | |
| path.endsWith('.cpp') || | |
| path.endsWith('.cxx') || | |
| path.endsWith('.h') || | |
| path.endsWith('.hpp') || | |
| path.endsWith('.m') || | |
| path.endsWith('.mm') | |
| ) { | |
| return cpp(); | |
| } |
Codemirror supports filename matching across all its built in languages: https://codemirror.net/docs/ref/#language.LanguageDescription^matchFilename
I think, mostly the task would be to actually call this before falling back to javascript.
The profile for screenshot:
ffprofile.json
┆Issue is synchronized with this Jira Task
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Jira
Severity
Estimate
Activity
mstange commentedon Nov 3, 2026
Sounds good, happy to accept a PR. The one thing we should keep an eye on is the size of the editor bundle chunk; you can ask esbuild for a metafile (I forgot how) and visualize it with https://esbuild.github.io/analyze/ .
[-]Feature: Support more languages in source view.[/-][+]Support more languages in source view[/+]zuhairkhalid229 commentedon Nov 18, 2026
Hi, I'd like to work on this if nobody else has started.
My plan: keep the existing Rust, C++ and JS/TS handling in
_languageExtForPath, and for any other extension look the file up withLanguageDescription.matchFilenamefrom@codemirror/language-data, loading the language on demand so each one ends up in its own small chunk and the editor chunk barely grows. I'll check that with an esbuild metafile as you suggested. Unknown extensions keep falling back to JS as today.One thing I'd keep as is: inline scripts use the page URL as their path, so a
.htmlor.phpmatch would still get JS highlighting rather than HTML.