bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix, GSTextStorage, replaceCharactersInRange:withString:


From: Georg Fleischmann
Subject: Fix, GSTextStorage, replaceCharactersInRange:withString:
Date: Sun, 22 Apr 2001 21:47:25 +0200

Hi,

here is a fix for GSTextStorage (snapshot from 2001-04-19).
The patch fixes a problem when replacing a range with a string of zero length:  
It recalculates the effective range to match the modified set of attributes  
before comparing with the effective range.
If this is not done and there were more than one attribute in the range which  
is being replaced, the (old) effective range wouldn't match the range being  
replaced, and a range of zero length would remain...

Georg


2001-04-22  Georg Fleischmann

        * gui/Source/GSTextStorage.m
        [GSTextStorage.m replaceCharactersInRange:withString:]:
        recalculate effective range after removing attributes


diff -u gui/Source/GSTextStorage.m.old gui/Source/GSTextStorage.m

--- gui/Source/GSTextStorage.m.old      Sat Jan 13 21:33:32 2001
+++ gui/Source/GSTextStorage.m  Sun Apr 22 21:36:40 2001
@@ -738,18 +738,25 @@
     }

   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--;
+        }
     }

   /*



reply via email to

[Prev in Thread] Current Thread [Next in Thread]