netbeans icon indicating copy to clipboard operation
netbeans copied to clipboard

JS wrong format indentation in switch nested in switch default

Open riksoft opened this issue 1 year ago • 0 comments

Apache NetBeans version

Apache NetBeans 21

What happened

In code like this

let a, b;
switch(a){
	case 0:
		//stuff
		break;
	case 1:
		//stuff
		break;
	default:
	switch(b){
		case 0:
			//stuff
			break;
	}
}

formatting with ALT+Shift+F the code is formatted you see above with the second switch at the same level of "default". A workaround is to add something else before between default and switch. Unfortunately cannot be a comment because it has the same problem. Must be code, e.g. a useless "let c;" will do.

let a, b;
switch(a){
	case 0:
		//stuff
		break;
	case 1:
		//stuff
		break;
	default:
		let c;
		switch(b){
			case 0:
				//stuff
				break;
		}
}```

### Language / Project Type / NetBeans Component

PHP project

### How to reproduce

Open a PHP project then add a JS file and try the above code.

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

No / Don't know

### Operating System

Debian Bookworm (12)

### JDK

Java: 17.0.10; OpenJDK 64-Bit Server VM 17.0.10+7-Debian-1deb12u1 Runtime: OpenJDK Runtime Environment 17.0.10+7-Debian-1deb12u1

### Apache NetBeans packaging

Apache NetBeans binary zip

### Anything else

_No response_

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

No

riksoft avatar Apr 05 '24 11:04 riksoft