Bug 41692 Pressing Enter at last caret position does not work
I20030819 This is in .log: org.eclipse.jdt.internal.corext.Assert$AssertionFailedException: assertion failed; at org.eclipse.jdt.internal.corext.Assert.isTrue(Assert.java:136) at org.eclipse.jdt.internal.corext.Assert.isTrue(Assert.java:121) at org.eclipse.jdt.internal.ui.text.java.JavaAutoIndentStrategy.firstNonWhitespaceBackward(JavaAutoIndentStrategy.java:501) at org.eclipse.jdt.internal.ui.text.java.JavaAutoIndentStrategy.isBracelessBlockStart(JavaAutoIndentStrategy.java:359) at org.eclipse.jdt.internal.ui.text.java.JavaAutoIndentStrategy.smartIndentAfterNewLine(JavaAutoIndentStrategy.java:330) at org.eclipse.jdt.internal.ui.text.java.JavaAutoIndentStrategy.customizeDocumentCommand(JavaAutoIndentStrategy.java:1187) at org.eclipse.jface.text.TextViewer.customizeDocumentCommand(TextViewer.java:3080) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$AdaptedSourceViewer.customizeDocumentCommand(CompilationUnitEditor.java:214) at org.eclipse.jface.text.TextViewer.handleVerifyEvent(TextViewer.java:3099) at org.eclipse.jface.text.TextViewer$TextVerifyListener.verifyText(TextViewer.java:318) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:189) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:848) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:872) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:665) at org.eclipse.swt.custom.StyledText.modifyContent(StyledText.java:5808) at org.eclipse.swt.custom.StyledText.sendKeyEvent(StyledText.java:6794) at org.eclipse.swt.custom.StyledText.doContent(StyledText.java:2546) at org.eclipse.swt.custom.StyledText.handleKey(StyledText.java:5187) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5210) at org.eclipse.swt.custom.StyledText$8.handleEvent(StyledText.java:4957) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:848) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:872) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1688) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1684) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3013) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2892) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2713) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1338) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1876) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1676) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1659) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583)
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.java
* Returns the minimal indent size of all non empty lines;
	 */
	private static int getMinimalIndentSize(String paragraph, boolean includeFirstLine, int tabWidth) {
		int minIndentSize= Integer.MAX_VALUE;
		
		for (final Iterator iterator= new LineIterator(paragraph); iterator.hasNext();) {
			final String line= (String) iterator.next();
			if (!includeFirstLine) {
				includeFirstLine= true;
				continue;
			}
			String indent= null;
			if (line.startsWith(COMMENT)) {
				String commentedLine= line.substring(2);
				
				
				if (commentedLine.trim().length() == 0)
					continue;
				
				indent= COMMENT + getIndentOfLine(commentedLine);				
			} else {
				
				if (line.trim().length() == 0)
					continue;
				indent=getIndentOfLine(line);
			}
			final int indentSize= calculateDisplayedWidth(indent, tabWidth);
			if (indentSize < minIndentSize)
				minIndentSize= indentSize;
		}