microsoft / microsoft/monaco-editor

[Bug] ".ini" syntax's indented comments are not highlighted

Open
#5,464 0 comments 0 reactions 1 assignee View on GitHub

@hediet is already working on this.

Since Sep 2, 2026.

Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.55.1#XQAAAAJcAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscwzXRwRgmSaumWUF-TBOsVJ4S4FwfCDQb5-2uUHXTVAefbVSd9IzaZ_vv9VR9KugsKigJST0nA_Uq1vIej6483BzQM5jBKzt1pJt3lgW3g3DB6np2m2xz_hotEPprSNO66e6aZcVz2n6z8P_WsqhZfMELFixRqmWc4Z9bkb0BLGJLX4DAvnGbxAE6VdSj9F4FiNEUm--ITRtpxBN9FQb5ABxGks4vbZqD3IM2kq5fBRZIozk8KdDbLEoYWMGlW-WeysfQpHPvxLz7PYlwA1h9kuP7IGgk

Monaco Editor Playground Code
const value = /* set from `myEditor.getModel()`: */ `; Comment
key = value

  ; Comment
  key = value
`;

// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
	value,
	language: "ini",
	automaticLayout: true,
});
Reproduction Steps
  1. Create an ".ini" file in Monaco
  2. Add an un-indented line ; Comment, and observe that it is highlighted
  3. Indent that line, such as ; Comment, and observe that it's no longer highlighted
Actual (Problematic) Behavior

Indented comments, such as ; Comment, are not highlighted

Expected Behavior

Indented comments should be highlighted, like is seen below in GitHub's syntax highlighting:

; Comment
    ; Comment
Additional Context

My agent says:

Root cause: Monaco's stock ini.ts defines the comment rule as /^\s*[#;].*$/ inside the  @whitespace  state. In  monarchCompile.ts , any rule whose regex starts with  ^  is flagged  matchOnlyAtLineStart=true  (and the  ^  is stripped). In  monarchLexer.ts  the match loop gates every rule with  if (pos === 0 || !rule.matchOnlyAtLineStart) . For an indented comment   ; comment , the sibling whitespace rule  /[ \t\r\n]+/  consumes the leading spaces first, advancing  pos  to 2; the comment rule is then skipped (pos≠0 and it's line-start-only), nothing else matches  ; , so Monaco applies  defaultToken  → the text renders white instead of comment-green. Non-indented comments work because  pos  is still 0 when the rule is reache

This issue is a pain for me because I'd very much like to indent our .ini files key/values and comments to make section headers foldable and easier to navigate, but if I attempt to do something like the below, our comments lose highlighting and wind up looking visually very similar to the key/value pairs:

[Section]
    ; Long comment explaining the reasons why we applied this
    ; setting, in what situations one might want to change it, and
    ; what the valid format for a new value is
    key = value

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.