Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2018-03-20 09:23:55 -0400
committerMickael Istria2018-03-20 11:12:42 -0400
commit6b6a803be8b3cee91b11f0494bbee7b35bb5e4bf (patch)
tree8375024fd47627f9002d49cd8bad618dd67f9669 /org.eclipse.jface.text/src
parent38559f9b3758759138fe4c90fee9e3d758d70f1b (diff)
downloadeclipse.platform.text-6b6a803be8b3cee91b11f0494bbee7b35bb5e4bf.tar.gz
eclipse.platform.text-6b6a803be8b3cee91b11f0494bbee7b35bb5e4bf.tar.xz
eclipse.platform.text-6b6a803be8b3cee91b11f0494bbee7b35bb5e4bf.zip
Bug 529617 - Fix line numbers in Compare Editor
Keeps text listener to update digits and column width + Remove useless field Change-Id: I12ed75aebe35495ee80d042c025a64e713eaf704 Signed-off-by: Mickael Istria <mistria@redhat.com>
Diffstat (limited to 'org.eclipse.jface.text/src')
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java40
1 files changed, 34 insertions, 6 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
index b1e24aaa5..a4cc78451 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/LineNumberRulerColumn.java
@@ -52,10 +52,12 @@ import org.eclipse.jface.util.Util;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension;
import org.eclipse.jface.text.ITextViewerExtension5;
import org.eclipse.jface.text.JFaceTextUtil;
+import org.eclipse.jface.text.TextEvent;
/**
@@ -77,6 +79,34 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
&& !"false".equals(System.getProperty("LineNumberRulerColumn.retina.workaround")) //$NON-NLS-1$ //$NON-NLS-2$
&& internalSupportsZoomedPaint();
+ /**
+ * Internal listener class.
+ */
+ class InternalListener implements ITextListener {
+
+ /**
+ * @since 3.1
+ */
+ private boolean fCachedRedrawState= true;
+
+ @Override
+ public void textChanged(TextEvent event) {
+
+ fCachedRedrawState= event.getViewerRedrawState();
+ if (!fCachedRedrawState)
+ return;
+
+ if (updateNumberOfDigits()) {
+ computeIndentations();
+ layout(event.getViewerRedrawState());
+ return;
+ }
+
+ boolean viewerCompletelyShown= isViewerCompletelyShown();
+ if (viewerCompletelyShown || event.getDocumentEvent() == null)
+ postRedraw();
+ }
+ }
/**
* Handles all the mouse interaction in this line number ruler column.
@@ -357,16 +387,14 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
private StyledText fCachedTextWidget;
/** The columns canvas */
private Canvas fCanvas;
- /** Cache for the actual scroll position in pixels */
- private int fScrollPos;
/** The drawable for double buffering */
private Image fBuffer;
+ /** The internal listener */
+ private ITextListener fInternalListener= new InternalListener();
/** The font of this column */
private Font fFont;
/** The indentation cache */
private int[] fIndentation;
- /** Indicates whether this column reacts on text change events */
- private boolean fSensitiveToTextChanges= false;
/** The foreground color */
private Color fForeground;
/** The background color */
@@ -632,6 +660,8 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
if (fCachedTextViewer != null) {
VisibleLinesTracker.track(fCachedTextViewer, lineHeightChangeHandler);
+ fCachedTextViewer.addTextListener(fInternalListener);
+
if (fFont == null) {
if (fCachedTextWidget != null && !fCachedTextWidget.isDisposed())
@@ -725,7 +755,6 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
gc.setBackground(getBackground(fCanvas.getDisplay()));
gc.fillRectangle(0, 0, width, height);
- fScrollPos= fCachedTextWidget.getTopPixel();
doPaint(gc, visibleLines);
} finally {
gc.dispose();
@@ -750,7 +779,6 @@ public class LineNumberRulerColumn implements IVerticalRulerColumn {
gc.setBackground(getBackground(fCanvas.getDisplay()));
gc.fillRectangle(0, 0, size.x, size.y);
- fScrollPos= fCachedTextWidget.getTopPixel();
doPaint(gc, visibleLines);
} finally {
gc.dispose();

Back to the top