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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DependenciesPull requests that update a dependency fileArea:EditorFor CodeMirror-related featuresBug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions