Skip to content

Syntax highlighting still not working for private fields (supported in ES2022) #2031

Open
@fabiopettinati

Description

@fabiopettinati

The editor doesn't highlight property fields correctly. Upon encountering any # symbol it displays the rest of the line in red color.

@josephh in discourse.processing.org identified the issue as being related to the use of CodeMirror in p5.web.editor. The issue in CodeMirror got fixed back in 2020 and perhaps the p5 editor is not using the mrs up-to-date version.

The code below will show the problem when opened in the editor. The lines ending in // <---- issue here are displayed in red starting with the # symbol.

function setup() {
class Acme {
#bar; // <---- issue here
constructor(v) { this.#bar = v; } // <---- issue here
get foo() { return this.#bar; } // <---- issue here
set foo(v) { this.#bar = v; } // <---- issue here
}

let acme = new Acme(7);
console.log(acme.foo); // expected output: 7
acme.foo = 5; // #bar now = 5
console.log(acme.foo); // expected output: 5
}

Activity

welcome

welcome commented on Jun 17, 2022

@welcome

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

added
BugError or unexpected behaviors
on Nov 9, 2022
Harshit-7373

Harshit-7373 commented on Feb 10, 2025

@Harshit-7373
Contributor

@fabiopettinati @raclim
This issue is likely due to an outdated version of CodeMirror, which does not correctly handle the # symbol for private class fields introduced in modern JavaScript (ES2021).

We need to update their CodeMirror dependency to a more recent version that supports the latest JavaScript syntax.

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

    Area: DependenciesPull requests that update a dependency fileArea:EditorFor CodeMirror-related featuresBugError or unexpected behaviors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @lindapaiste@raclim@fabiopettinati@Harshit-7373

        Issue actions

          Syntax highlighting still not working for private fields (supported in ES2022) · Issue #2031 · processing/p5.js-web-editor