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
int end= findEndOfWhiteSpace(document, start, offset);
		
		return document.get(start, end - start);
	}
	private String getModifiedText(String string, String indentation, String delimiter) throws BadLocationException {		
		return displayString(string, indentation, delimiter);
	}
	private void javaStringIndentAfterNewLine(IDocument document, DocumentCommand command) throws BadLocationException {
		ITypedRegion partition= TextUtilities.getPartition(document, fPartitioning, command.offset);
		int offset= partition.getOffset();
		int length= partition.getLength();
		if (command.offset == offset)
			return;
		
		if (command.offset == offset + length && document.getChar(offset + length - 1) == '\"')
			return;
		String indentation= getLineIndentation(document, command.offset);
		String delimiter= TextUtilities.getDefaultLineDelimiter(document);
		IRegion line= document.getLineInformationOfOffset(offset);
		String string= document.get(line.getOffset(), offset - line.getOffset());
		if (string.trim().length() != 0)
			indentation += String.valueOf("\t\t"); 
		
		IPreferenceStore preferenceStore= JavaPlugin.getDefault().getPreferenceStore();
		if (isLineDelimiter(document, command.text))
			command.text= "\" +" + command.text + indentation + "\"";  
		else if (command.text.length() > 1 && preferenceStore.getBoolean(PreferenceConstants.EDITOR_ESCAPE_STRINGS))
			command.text= getModifiedText(command.text, indentation, delimiter);