Bug 203400 - Nested switch statements don't format as expected
Summary: Nested switch statements don't format as expected
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: PDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: ---   Edit
Assignee: Alon Peled CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-09-14 00:24 EDT by Tom Walter CLA
Modified: 2020-05-14 11:08 EDT (History)
4 users (show)

See Also:
ganoro: iplog+


Attachments
contributed by zhongwei zhao (1.02 KB, patch)
2009-03-20 04:00 EDT, Roy Ganor CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Walter CLA 2007-09-14 00:24:48 EDT
If a switch case contains a nested switch case, using the code formatter makes subsequent cases indent too far.

Try the following test case with the code formatter:

switch ("1") {
	case "1a":
		switch ("2") {
			case "2a":
				break;
			case "2b":
				break;
		}
		break;
			case "1b":
				break;
			case "1c":
				switch ("3") {
					case "3a":
						break;
					case "3b":
						break;
				}
				break;
					case "1d":
						break;
}

Note case 1b and 1c are indented as if they were part of switch 2. Then because 1c contains another nested switch, 1d is indented as if it were part of switch 3.

What I would expect to see is:

switch ("1") {
	case "1a":
		switch ("2") {
			case "2a":
				break;
			case "2b":
				break;
		}
		break;
	case "1b":
		break;
	case "1c":
		switch ("3") {
			case "3a":
				break;
			case "3b":
				break;
		}
		break;
	case "1d":
		break;
}
Comment 1 Gadi Goldbarg CLA 2008-12-01 10:57:39 EST
Reproducible in PDT 2.0.0 as well
Tested on Wix XP
Eclipse SDK
Version: 3.4.1
Build id: M20080911-1700
debugger - org.zend.php.debug_feature-I20081127
pdt - N20081130
dltk-core-sdk-I-I200811251145-200811251145-incubation

[Kalin Yanev kalin.a@zend.com]
Comment 2 Roy Ganor CLA 2009-03-20 04:00:24 EDT
Created attachment 129422 [details]
contributed by zhongwei zhao
Comment 3 Roy Ganor CLA 2009-03-20 04:04:37 EDT
fixed in HEAD.

contributed by zhongwei zhao
Comment 4 Gadi Goldbarg CLA 2009-05-08 04:10:09 EDT
re-tested in PDT M7.
Verified fixed.

kalin yanev - kalin.a@zend.com