Skip to content

Commented-out JSONC lines still get full JSON syntax highlighting #55

Open

Description

@GordonBeeming

What happens

Open a JSONC file (JSON with // comments, like the cmux settings template) and the commented-out lines keep their full JSON syntax highlighting — keys stay red, strings green, booleans amber. Only the // markers hint that the block is inert, so at a glance the file reads as if all those settings are active.

Commented JSONC lines still showing full JSON token colours

What should happen

Everything after // on a comment line renders in the muted comment colour, the way any other language's comments do.

Likely cause

.json files load the plain JSON grammar (src/language.ts), which has no comment support, so the parser treats // lines as ordinary (broken) JSON tokens and highlights them. Probably wants the JSONC variant of the CodeMirror JSON language for .json/.jsonc, or at least for .jsonc plus known comment-friendly files.

Repro

  1. Open any .json file that uses // comments (cmux's generated cmux.json template is a ready-made example).
  2. Look at the commented block - full token colours instead of comment styling.

Seen on v0.7 (dark theme, but theme-independent).

Activity

  1. added
    bug
    on Jul 10, 2026
  2. bhsd-harry commented on Sep 24, 2026

    @bhsd-harry

    Hi! If you are looking for a Lezer grammar for JSONC, you may consider my package @bhsd/lezer-json. It is a fork of @lezer/json and @codemirror/lang-json, and provides JSONC as a dialect of JSON. This package has already been used by MediaWiki (powering websites including Wikipedia).

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions