processing / processing/p5.js-web-editor

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

Open
#2,031 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area: Dependencies Area:Editor Bug
Dominant language
JavaScript
Stars
1.7k
Forks
1.7k
Avg merge
3d 4h
Merged PRs (30d)
8

Description

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
}

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.

Research direction

Reproduce the issue in the p5.web.editor with the private-field example from the report, then inspect how the editor integrates CodeMirror and which version it uses. Compare that integration with the CodeMirror fix mentioned in the issue. Done means #bar declarations and accesses no longer turn the remainder of each line red.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.