Skip to content

[Request] Allow Scintilla's option to enable/disable comments highlighting for JSON files #11713

@tilleul

Description

@tilleul

Description of the Issue

Although comments are not officially supported in JSON files, many subsets of JSON allow comments.
According to notepad-plus-plus/userDefinedLanguages#58
and https://community.notepad-plus-plus.org/topic/19486/help-with-json-and-scintilla-lexer/2?lang=fr
Scintilla highlighting engine has a options.allowComments variable in the JSON lexer that would allow the highlight of comments. This option is not accessible from NPP. Also notice that the "Style configurator" has styles for "LINECOMMENT" and "BLOCKCOMMENT" for JSON files but these styles are not applied (because "allowComments" is set to false as default).

Could the "allowComments" option be added to Settings/Preferences/Languages screen in the same way that "Treat backslash as escape character for SQL" is an option on this screen ?

Steps to Reproduce the Issue

Create a new file, set Language to JSON and type

{
    "myProperty": "any value" // this comment is treated as an error (red)
}

Expected Behavior

{
    "myProperty": "any value" // this comment should be treated as a comment if "allowComments" option is set
}

Actual Behavior

Line comments and block comments are treated as errors.

Debug Information

not applicable (request feature)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions