brute-force range restriction to avoid spurious crashes;
authorwenzelm
Thu, 16 Jun 2011 22:15:35 +0200
changeset 43415 8f7494985093
parent 43414 f0770743b7ec
child 43416 e730cdd97dcf
brute-force range restriction to avoid spurious crashes;
src/Tools/jEdit/src/text_area_painter.scala
--- a/src/Tools/jEdit/src/text_area_painter.scala	Thu Jun 16 22:05:40 2011 +0200
+++ b/src/Tools/jEdit/src/text_area_painter.scala	Thu Jun 16 22:15:35 2011 +0200
@@ -231,8 +231,11 @@
         else {
           var x1 = x + w
           for (Text.Info(range, info) <- markup) {
-            // FIXME range check!?
-            val str = chunk.str.substring(range.start - chunk_offset, range.stop - chunk_offset)
+            // FIXME proper range!?
+            val str =
+              chunk.str.substring(
+                (range.start - chunk_offset) max 0,
+                (range.stop - chunk_offset) min chunk_length)
             gfx.setColor(info.getOrElse(chunk_color))
             if (range.contains(caret_offset)) {
               val astr = new AttributedString(str)