apache / apache/netbeans

Bracket was added on wrong position

Open
#4,279 0 comments 0 reactions 0 assignees View on GitHub
JavaScript kind:bug needs:triage
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 14

### What happened

Take this piece of code

```javascript
const teste = {
tester: {
test: 2
}
};
```

When you remove the closing bracket on line 4 and delete all spaces and so that the cursor is on line start and hit "}" to readd the closing bracket, it will be added right under the first token letter of test and not on the position where it was expected which is the same indentation column as tester started.

![wrong-formatting-closing-bracket](https://user-images.githubusercontent.com/795658/175322077-02f2f218-940e-49a1-aba0-bb65837903f1.gif)

### How to reproduce

* Open/Create a new JS file inside an HTML5 Project
* Type the example code in
* Go to the line with the closing bracket after the property test
* Remove the closing bracket
* Remove all spaces and set cursor to the start of the line
* hit "}" to add the closing bracket again
* See that the closing bracket is at the wrong column (please see my little screencast)

### Did this work correctly in an earlier version?

No

### Operating System

Windows 11

### JDK

OpenJDK Runtime Environment 14+36-1461

### Apache NetBeans packaging

Apache NetBeans provided installer

### Anything else

All that I tested was with a fresh and clean installation of Apache NetBeans 14.

### Are you willing to submit a pull request?

No

### Code of Conduct

Yes

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in a fresh Apache NetBeans 14 installation by creating a JavaScript file inside an HTML5 Project and following the listed bracket-editing steps. Investigate the JavaScript editor's indentation behavior; done means re-adding the closing bracket places it in the same indentation column where the tester property started.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.