Skip to content

Incorrect bracket matching when JavaScript identifier contains $ #2236

Description

@velteyn

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.

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions