Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 354324

Summary: [typing] foreach statements that aren't followed by braced blocks mess up indentation
Product: [Eclipse Project] JDT Reporter: rezecib Mising name <rezecib>
Component: TextAssignee: JDT-Text-Inbox <jdt-text-inbox>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert
Version: 3.8   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description rezecib Mising name CLA 2011-08-10 01:52:42 EDT
Build Identifier: I20110613-1736 

Indentation does not work properly after one-line (no-brace) foreach statements.
Example code:

public class Bork
{
	public static void method()
	{
		int sum = 0;
		int[][] grid = new int[9][9];
		
		for(int r = 0; r < 9; r++)
			for(int c = 0; c < 9; c++)
				sum++;
		sum = 0;
		
		for(int[] row : grid)
			for(int el : row)
				sum++;
					sum = 0;
	}
}

Reproducible: Always

Steps to Reproduce:
1.Write a foreach statement
2.Fill its block with only one statement, and don't use braces
3.Hit enter and type another statement
Comment 1 Dani Megert CLA 2011-08-10 04:01:05 EDT

*** This bug has been marked as a duplicate of bug 348198 ***