Bug 46875 [typing] Tabs are messed up
When I type code that has string literals in it, and press enter to move the string literal to the next line, the tab logic seems strange. e.g. String twoLines = "System Contains Many Defects,Systemet innehaller manga fel\n"+"Stories Are Too Complicated,Stories ar for komplicerade"; Move the cursor after + and press enter. It somehow moves the new line to column 0, while I'd expect it to align with the first line. If you try this with a single string, the bug will still be seen. Interestingly, when I am within a method's parantheses, the behavior is different. e.g. assertEquals( "converted data", "Systemet+innehaller+manga+fel|Stories+ar+for+komplicerade",convertedData .toString() ); Note, the two lines within have a single tab each. Now position the cursor on convertedData and press enter - while I'd expect it to line up with the previous line (two tabs), the IDE adds three tabs. Now here's the one which really annoys me: assertEquals( There is one tab before assertEquals. Press enter after the paranthesis. Three tabs are inexplicably put in. I would expect only two. I am assuming these are bugs as previous releases had the right behavior. Regards, Somik
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaStringAutoIndentStrategy.java
StringBuffer buffer = new StringBuffer(length);
		java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(inputString, "\n\r", true); 
		while (tokenizer.hasMoreTokens()){
	
			String token = tokenizer.nextToken();
			if (token.equals("\r")) { 
				buffer.append("\\r"); 
				if (tokenizer.hasMoreTokens()) {
					token = tokenizer.nextToken();
					if (token.equals("\n")) { 
						buffer.append("\\n"); 
						buffer.append("\" + " + delimiter); 
						buffer.append(indentation);
						buffer.append("\""); 
						continue;
					} else {
						buffer.append("\" + " + delimiter); 
						buffer.append(indentation);
						buffer.append("\""); 
					}
				} else {
					continue;
				}
			} else if (token.equals("\n")) { 
				buffer.append("\\n"); 
				buffer.append("\" + " + delimiter); 
				buffer.append(indentation);
				buffer.append("\""); 
				continue;
			}