diff options
author | angelozerr | 2018-03-02 14:35:16 +0000 |
---|---|---|
committer | angelozerr | 2018-03-02 14:35:16 +0000 |
commit | 5c81b44cc8388a70cdacd82f0f567fd5b6f8e1b0 (patch) | |
tree | acc6ea208ad5cd5775b119dae3041b0acc8cdf77 /org.eclipse.jface.text/src/org/eclipse/jface/text | |
parent | 59bad5b81b3c0830f54c9076fe6db0d78cc19866 (diff) | |
download | eclipse.platform.text-5c81b44cc8388a70cdacd82f0f567fd5b6f8e1b0.tar.gz eclipse.platform.text-5c81b44cc8388a70cdacd82f0f567fd5b6f8e1b0.tar.xz eclipse.platform.text-5c81b44cc8388a70cdacd82f0f567fd5b6f8e1b0.zip |
Bug 531920 - [CodeMining] CodeMining annotation doesn't appear when textI20180306-2000I20180306-0800I20180305-2000I20180305-0800I20180305-0300I20180304-2000I20180304-0800I20180303-1500I20180303-1200I20180303-0800I20180303-0335I20180303-0155I20180303-0055I20180302-2000
are added
Change-Id: I4af56cce8ccaec1b0ded4d31bf564610779e528e
Signed-off-by: angelozerr <angelo.zerr@gmail.com>
Diffstat (limited to 'org.eclipse.jface.text/src/org/eclipse/jface/text')
-rw-r--r-- | org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java index df1e7b9401e..8bb1e7a5598 100644 --- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java +++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/inlined/InlinedAnnotationSupport.java @@ -36,7 +36,9 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.core.runtime.Assert; import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; +import org.eclipse.jface.text.IDocumentListener; import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ISynchronizable; import org.eclipse.jface.text.ITextPresentationListener; @@ -123,17 +125,17 @@ public class InlinedAnnotationSupport implements StyledTextLineSpacingProvider { * Class to track start/end offset of visible lines. * */ - private class VisibleLines implements IViewportListener { + private class VisibleLines implements IViewportListener, IDocumentListener { private int startOffset; - private int endOffset; + private Integer endOffset; public VisibleLines() { fViewer.getTextWidget().getDisplay().asyncExec(() -> { - startOffset= getInclusiveTopIndexStartOffset(); - endOffset= getExclusiveBottomIndexEndOffset(); + compute(); }); + fViewer.getDocument().addDocumentListener(this); } @Override @@ -141,6 +143,17 @@ public class InlinedAnnotationSupport implements StyledTextLineSpacingProvider { compute(); } + @Override + public void documentAboutToBeChanged(DocumentEvent event) { + endOffset= null; + } + + @Override + public void documentChanged(DocumentEvent event) { + // Do nothing + } + + @SuppressWarnings("boxing") private void compute() { startOffset= getInclusiveTopIndexStartOffset(); endOffset= getExclusiveBottomIndexEndOffset(); @@ -194,9 +207,22 @@ public class InlinedAnnotationSupport implements StyledTextLineSpacingProvider { * @return <code>true</code> if the given offset is in visible lines and <code>false</code> * otherwise. */ - public boolean isInVisibleLines(int offset) { + @SuppressWarnings("boxing") + boolean isInVisibleLines(int offset) { + if (endOffset == null) { + endOffset= getExclusiveBottomIndexEndOffset(); + } return offset >= startOffset && offset <= endOffset; } + + /** + * Uninstall visible lines + */ + void uninstall() { + if (fViewer != null && fViewer.getDocument() != null) { + fViewer.getDocument().removeDocumentListener(this); + } + } } private class MouseTracker implements MouseTrackListener, MouseMoveListener, MouseListener { @@ -353,6 +379,10 @@ public class InlinedAnnotationSupport implements StyledTextLineSpacingProvider { } fViewer.removeViewportListener(visibleLines); } + if (visibleLines != null) { + visibleLines.uninstall(); + visibleLines= null; + } fViewer= null; fPainter= null; } |