use a sorted set to store the StyleRanges
because there are so many style ranges created , looping through a list really is slow.
Now it jumps to the right style offset and terminates if it offset+length falls out of the current selection.
diff --git a/core/plugins/org.eclipse.dltk.console.ui/src/org/eclipse/dltk/console/ui/ScriptConsolePartitioner.java b/core/plugins/org.eclipse.dltk.console.ui/src/org/eclipse/dltk/console/ui/ScriptConsolePartitioner.java
index f57b5e2..f1f8355 100644
--- a/core/plugins/org.eclipse.dltk.console.ui/src/org/eclipse/dltk/console/ui/ScriptConsolePartitioner.java
+++ b/core/plugins/org.eclipse.dltk.console.ui/src/org/eclipse/dltk/console/ui/ScriptConsolePartitioner.java
@@ -11,8 +11,11 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Comparator;
 import java.util.Iterator;
 import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
 
 import org.eclipse.jface.text.rules.FastPartitioner;
 import org.eclipse.jface.text.rules.IPredicateRule;
@@ -27,7 +30,18 @@
 public class ScriptConsolePartitioner extends FastPartitioner implements
 		IConsoleDocumentPartitioner {
 
-	private List ranges = new ArrayList();
+	private SortedSet ranges = new TreeSet(new Comparator() {
+
+		public int compare(Object o1, Object o2) {
+			StyleRange sr1 = (StyleRange) o1;
+			StyleRange sr2 = (StyleRange) o2;
+			int start = sr1.start - sr2.start;
+			if (start == 0) {
+				return sr1.length - sr2.length;
+			}
+			return start;
+		}
+	});
 
 	private static class Constants {
 		public static final String MY_DOUBLE_QUOTED = "__my_double"; //$NON-NLS-1$
@@ -72,17 +86,23 @@
 
 	public StyleRange[] getStyleRanges(int offset, int length) {
 		List result = new ArrayList();
-		for (Iterator iterator = ranges.iterator(); iterator.hasNext();) {
+		// get the sublist with length = 0 so that it will return all with that
+		// offset.
+		StyleRange sr = new StyleRange(offset, 0, null, null, SWT.NO);
+		for (Iterator iterator = ranges.tailSet(sr).iterator(); iterator
+				.hasNext();) {
 			StyleRange r = (StyleRange) iterator.next();
 			if (r.start >= offset && r.start + r.length <= offset + length)
 				result.add((StyleRange) r.clone());
+			else
+				break;
 		}
 
 		if (result.size() > 0)
 			return (StyleRange[]) result.toArray(new StyleRange[result.size()]);
 
-		return new StyleRange[] { new StyleRange(offset, length, null, null,
-				SWT.NO) };
+		sr.length = length;
+		return new StyleRange[] { sr };
 	}
 
 	public boolean isReadOnly(int offset) {