This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 257773

Summary: Indentation of lambda body not consistent with non-lambda code
Product: editor Reporter: _ gtzabari <gtzabari>
Component: Formatting & IndentationAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.2   
Hardware: PC   
OS: Other   
Issue Type: DEFECT Exception Reporter:

Description _ gtzabari 2016-01-30 08:50:53 UTC
Product Version: NetBeans IDE Dev (Build 201601210002)
Updates: Updates available
Java: 1.8.0_71; Java HotSpot(TM) 64-Bit Server VM 25.71-b15
Runtime: Java(TM) SE Runtime Environment 1.8.0_71-b15
System: Windows 10 version 10.0 running on amd64; UTF-8; en_CA (nb)
User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev
Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev

Given:

Set<Integer> values = IntStream.range(1, 5).map(value ->
{
	return 5;
}.
collect(Collectors.toSet());

Netbeans is formatting it as:

Set<Integer> values = IntStream.range(1, 5).map(value ->
{
	return 5;
}.
	collect(Collectors.toSet());

If, however, you invoke code-format on:

Set<Integer> values = IntStream.range(1, 5).
map(value ->
{
	return 5;
}.
	collect(Collectors.toSet());

You will get:

Set<Integer> values = IntStream.range(1, 5).
	map(value ->
	{
		return 5;
	}.
		collect(Collectors.toSet());

In other words, Netbeans is always indenting collect() one level deeper than the lambda function.

Expected behavior: lambda body should have the same indentation level as collect().