From ab02462cdcba7f5f9aa64f1f1a02aafb7ca70235 Mon Sep 17 00:00:00 2001 From: Jonah Graham Date: Thu, 24 May 2018 21:05:56 +0100 Subject: [PATCH] Bug 519391: Only redraw the changed lines When a line is double-clicked, or the highlight error is otherwise changed, the redrawing of the highlighting was done by redrawing the entire build console document. This was slow on very large documents. Instead only redraw the line losing the highlight (if any) and the line gaining the highlight. In addition, as we only change the foreground colour to highlight, avoid redrawing the background. Change-Id: I5e652449715a588cb8702e0100a472d1f566e2a8 --- .../cdt/internal/ui/buildconsole/BuildConsolePage.java | 8 +++++++- .../internal/ui/buildconsole/BuildConsoleViewer.java | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java index f31e5422ad8..3581ae5abc8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2017 QNX Software Systems and others. + * Copyright (c) 2002, 2018 QNX Software Systems 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 @@ -584,6 +584,9 @@ public class BuildConsolePage extends Page if (console == null) return; if (console instanceof BuildConsolePartitioner) { BuildConsolePartitioner par = (BuildConsolePartitioner)console; + + BuildConsolePartition oldPartition = par.fDocumentMarkerManager.getCurrentPartition(); + // Move to specified line in the model (BuildConsolePartitioner) if ( position == POSITION_NEXT ) { par.fDocumentMarkerManager.moveToNextError(); @@ -597,6 +600,9 @@ public class BuildConsolePage extends Page return; } } + if (oldPartition != null) { + getViewer().deselectPartition(par, oldPartition); + } showError(par, position > 0 || fShowErrorAction.isChecked() ); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java index d0be3b589c7..21658a0abb0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java @@ -183,6 +183,14 @@ public class BuildConsoleViewer extends TextViewer event.styles = styles; } + public void deselectPartition(BuildConsolePartitioner partitioner, BuildConsolePartition p) { + StyledText st = getTextWidget(); + if (st != null) { + // Deselect line + st.redrawRange(p.getOffset(), p.getLength(), false); + } + } + public void selectPartition(BuildConsolePartitioner partitioner, BuildConsolePartition p) { StyledText st = getTextWidget(); if (st != null) { @@ -202,7 +210,7 @@ public class BuildConsoleViewer extends TextViewer } // Select line - st.redrawRange(0, partitioner.getDocument().getLength(), true); + st.redrawRange(p.getOffset(), p.getLength(), false); } catch (BadLocationException e) { CUIPlugin.log(e);