Bug 439419 - Form feed character causes unexpected scrolling

Patch submitted by Anton Leherbauer via https://git.eclipse.org/r/36271

Change-Id: I054161fa990ff14b970335b1aa88b36d9e85b065
Signed-off-by: Arun Thondapu <arunkumar.thondapu@in.ibm.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
index ac55b22..ae4cee8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java
@@ -7,6 +7,7 @@
  *
  * Contributors:
  *     IBM Corporation - initial API and implementation
+ *     Anton Leherbauer (Wind River Systems) - Bug 439419
  *******************************************************************************/
 package org.eclipse.swt.custom;
 
@@ -1005,17 +1006,19 @@
 					}
 				}
 			}
+			styledText.calculateScrollBars();
 			if (styledText.verticalScrollOffset != 0) {
 				int topIndex = styledText.topIndex;
 				int topIndexY = styledText.topIndexY;
 				int lineHeight = getLineHeight();
+				int newVerticalScrollOffset;
 				if (topIndexY >= 0) {
-					styledText.verticalScrollOffset = (topIndex - 1) * lineHeight + lineHeight - topIndexY;
+					newVerticalScrollOffset = (topIndex - 1) * lineHeight + lineHeight - topIndexY;
 				} else {
-					styledText.verticalScrollOffset = topIndex * lineHeight - topIndexY;
+					newVerticalScrollOffset = topIndex * lineHeight - topIndexY;
 				}
+				styledText.scrollVertical(newVerticalScrollOffset - styledText.verticalScrollOffset, true);
 			}
-			styledText.calculateScrollBars();
 			if (styledText.isBidiCaret()) styledText.createCaretBitmaps();
 			styledText.caretDirection = SWT.NULL;
 			styledText.setCaretLocation();