Skip to content

Support more languages in source view #6436

Description

@laundmo

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:

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.

Image

The profile for screenshot:
ffprofile.json

┆Issue is synchronized with this Jira Task

Activity

  1. mstange commented on Nov 3, 2026

    @mstange
    Contributor

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

  2. added
    source view
    on Nov 9, 2026
  3. added theissue type on Nov 9, 2026
  4. updated Priority P3 and Severity N/A on Nov 9, 2026
  5. changed the title [-]Feature: Support more languages in source view.[/-] [+]Support more languages in source view[/+] on Nov 9, 2026
  6. zuhairkhalid229 commented on Nov 18, 2026

    @zuhairkhalid229
    Contributor

    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 with LanguageDescription.matchFilename from @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 .html or .php match would still get JS highlighting rather than HTML.

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

Metadata

Metadata

Labels

source view

Type

Fields

Priority

P3

Jira

None yet

Severity

N/A

Estimate

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions