From f309b2992e2b089694ddea71b17605ac24b1022b Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Wed, 13 May 2009 11:30:53 +0000 Subject: [PATCH] Bug 275645 - BadLocationException saving file --- .../src/org/eclipse/cdt/internal/ui/util/EditorUtility.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java index e0e93cce132..e4524ce8b4f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/util/EditorUtility.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 QNX Software Systems and others. + * Copyright (c) 2000, 2009 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 @@ -824,10 +824,11 @@ public class EditorUtility { // forAll r1,r2 element differences: r1.rightStart() < r2.rightStart() -> r1.rightEnd() < r2.rightStart List regions= new ArrayList(); + final int numberOfLines= currentDocument.getNumberOfLines(); for (int i= 0; i < differences.length; i++) { RangeDifference curr= differences[i]; if (curr.kind() == RangeDifference.CHANGE) { - int startLine= curr.rightStart(); + int startLine= Math.min(curr.rightStart(), numberOfLines - 1); int endLine= curr.rightEnd() - 1; IRegion startLineRegion;