From 33cc5feb490d41759ef09b70c63ad17e58dffdfb Mon Sep 17 00:00:00 2001 From: CaS Date: Mon, 23 Apr 2001 09:32:45 +0000 Subject: [PATCH] Text storage fix. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9667 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/GSTextStorage.m | 29 ++++++++++++++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5073a408b..dc247628a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-04-22 Georg Fleischmann + + * gui/Source/GSTextStorage.m: + ([GSTextStorage.m replaceCharactersInRange:withString:]) + recalculate effective range after removing attributes. + 2001-04-23 Fred Kiefer * Source/NSColor.m: diff --git a/Source/GSTextStorage.m b/Source/GSTextStorage.m index 9feb05dc9..b73b6f82b 100644 --- a/Source/GSTextStorage.m +++ b/Source/GSTextStorage.m @@ -738,18 +738,25 @@ SANITY(); } moveLocations = [aString length] - range.length; - if (effectiveRange.location == range.location - && effectiveRange.length == range.length - && (moveLocations + range.length) == 0) + + /* + * If we are replacing a range with a zero length string and the + * range we are using matches the range replaced, then we must + * remove it from the array to avoid getting a zero length range. + */ + if ((moveLocations + range.length) == 0) { - /* - * If we are replacing a range with a zero length string and the - * range we are using matches the range replaced, then we must - * remove it from the array to avoid getting a zero length range. - */ - arrayIndex--; - REMOVEAT(arrayIndex); - arraySize--; + attrs = _attributesAtIndexEffectiveRange(start, &effectiveRange, + tmpLength, _infoArray, &arrayIndex); + arrayIndex ++; + + if (effectiveRange.location == range.location + && effectiveRange.length == range.length) + { + arrayIndex--; + REMOVEAT(arrayIndex); + arraySize--; + } } /*