apache / apache/netbeans

Wrong formatting inside JavaScript object by hitting "."

Open
#4,277 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

When you have this piece of code:

```javascript
const test = {

};
```
and you hit enter after the open bracket, it will auto indent n-spaces depends on the defaults/settings. For me it is 4 spaces. When you now hit ".", the formatting jumps 8 spaces further which is not correct.

```javascript
const test = {
.
};
```
![js-misformatting](https://user-images.githubusercontent.com/795658/175318390-d90fc8c4-fb8d-45b3-95f3-8459ff5cab84.gif)

### How to reproduce

* Open/Create a new JS file inside an HTML5 Project
* Type the example code in
* Go to the new line between the brackets and hit "."
* It will add more spaces than expected. Doesn't matter whether the cursor is on position 0 or on the indentation (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

I also set the JavaScript features to "ESNext" that also didn't work out.

### 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 JavaScript file inside an HTML5 Project using the example object and the configured indentation. Start by tracing the JavaScript editor formatting or indentation behavior triggered when "." is entered; done means the cursor keeps the expected indentation instead of jumping eight spaces further.

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
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.