Skip to content

Handlebars syntax highlighter does not recognize end of comment when using whitespace control (~) before closing braces #112

@alexr00

Description

@alexr00

Bug Description

In Handlebars templates, VSCode's syntax highlighting fails to properly recognize the end of a comment block when a whitespace control character (~) is used just before the closing delimiter. As a result, the line following the comment is incorrectly highlighted as if it were still part of the comment.

The following snippet demonstrates the bug:

    {{!-- This is a comment --~}}
    But this is not

The second line, But this is not, is rendered as a comment, but it should not be.

Steps to Reproduce:

  1. Paste the following Handlebars code into a .hbs file in VSCode:
    {{!-- This is a comment --~}}
    But this is not
  2. Observe the syntax highlighting of the second line.

Expected:

  • Only the first line should be highlighted as a comment.
  • The second line should be highlighted as normal Handlebars content.

Actual:

  • The second line is improperly highlighted as a comment.

Notes:

  • This issue occurs with the built-in Handlebars syntax highlighting in the latest VSCode version.
  • The bug seems to be specific to comments that use the Handlebars whitespace control character (~) before the closing braces.
  • Extensions disabled: Yes (still reproduces)
  • VS Code Version: 1.123.0
  • OS Version: MacOS 26.5

Originally from @jmpri3 in microsoft/vscode#320133

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions