From 42b59348e6a0ba525eb9f9b0dd6838706eaaa77e Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Mon, 19 Feb 2007 14:36:26 +0000 Subject: [PATCH] Workaround for platform bug 174419 --- .../internal/ui/LineBackgroundPainter.java | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java index 6389acb20eb..384b4c86996 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 Wind River Systems, Inc. and others. + * Copyright (c) 2007 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -348,9 +348,14 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Trigger redraw of given text positions. + * + * @param positions */ private void redrawPositions(List positions) { - final int minOffset= fTextViewer.getTopIndexStartOffset(); + // TextViewer.getTopIndexStartOffset is buggy + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=174419 +// final int minOffset= fTextViewer.getTopIndexStartOffset(); + final int minOffset= getTopIndexStartOffset(); final int maxOffset= fTextViewer.getBottomIndexEndOffset()+3; Rectangle clientArea= fTextWidget.getClientArea(); int width= clientArea.width + fTextWidget.getHorizontalPixel(); @@ -387,6 +392,20 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { } } + /** + * Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=174419 + * @return the offset of the topmost visible line + * @see ITextViewer#getTopIndexStartOffset() + */ + private int getTopIndexStartOffset() { + if (fTextWidget != null) { + int top= fTextWidget.getTopIndex(); + top= fTextWidget.getOffsetAtLine(top); + return getDocumentOffset(top); + } + return -1; + } + /* * @see org.eclipse.jface.text.IPainter#deactivate(boolean) */