Incorrect bracket matching when JavaScript identifier contains $

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
devtools

Research direction

Look at the bracket matching logic in the JavaScript editor, likely in a language server or syntax highlighting component. Start by searching for files handling bracket matching or tokenization for JavaScript. Reproduce the issue locally with the provided test case to confirm the bug. Check how '$' is being interpreted in identifiers and adjust the matching rules to treat it as part of an identifier, not a bracket.

Written by the indexing model from the issue text.

Description

In the JavaScript editor, bracket matching incorrectly associates an opening { with a $ character instead of the corresponding closing }.

This is reproducible in a completely new, empty .js file, so it does not appear to be related to the project, existing source code, or workspace configuration.

Steps to reproduce
  1. Create a new empty JavaScript file, for example test.js.
  2. Enter the following code:
function test() {
    const $this = $(this);
}
  1. Place the cursor on the opening { after function test().
Actual result

The $ character in $this / $(this) is highlighted as the matching character.

For example:

function test() {
    const $this = $(this);
          ^

The $ is highlighted instead of the closing }.

Expected result

The corresponding closing brace should be highlighted:

function test() {
    const $this = $(this);         
}
^
                                  

The $ character is valid in JavaScript identifiers and should not be treated as a bracket or matching character.

Additional information

The problem is reproducible with a completely new JavaScript file containing only the above code.

Try removing the $s from the file and I see that NO } is highlighted

Environment
  • Eclipse IDE: 4.41
  • Eclipse Wild Web Developer: 1.4.1.202608181434
  • Feature: org.eclipse.wildwebdeveloper.feature.feature.group
  • Operating system: Windows
  • Language: JavaScript
Notes

The issue also occurs in existing JavaScript source code, including code using jQuery, but jQuery itself does not appear to be relevant because the minimal example above reproduces the problem.

The problem affects only the visual bracket matching/highlighting; the JavaScript code itself is valid.

Dominant language
Java
Stars
203
Forks
76
Avg merge
1d 5h
Merged PRs (30d)
30

Getting set up

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.

More from eclipse-wildwebdeveloper/wildwebdeveloper

All issues in eclipse-wildwebdeveloper/wildwebdeveloper

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.