fixed removal of an association-emphasis by key.
authorClaus Gittinger <cg@exept.de>
Thu, 14 Oct 1999 00:37:50 +0200
changeset 834 08c8f9d9ca0a
parent 833 a0311a2e96cb
child 835 180efa0787ce
fixed removal of an association-emphasis by key.
Text.st
--- a/Text.st	Wed Oct 13 21:49:21 1999 +0200
+++ b/Text.st	Thu Oct 14 00:37:50 1999 +0200
@@ -437,7 +437,7 @@
 removeEmphasis:e1 from:e2
     "remove an emphasis; if it was not in e1, do nothing"
 
-    |ne|
+    |ne idx|
 
     e1 isNil ifTrue:[^ nil].
     e2 isNil ifTrue:[^ e1].
@@ -454,7 +454,7 @@
     ].
     e2 isAssociation ifTrue:[
         e1 isSymbol ifTrue:[
-            e2 key == e2 ifTrue:[^ nil].
+            e2 key == e1 ifTrue:[^ nil].
             ^ e2
         ].
         e1 isAssociation ifTrue:[
@@ -464,6 +464,7 @@
         (e1 includes:e2) ifTrue:[^ nil].
         ^ e2
     ].
+    "/ e2 must be a collection
     (e1 isSymbol 
      or:[e1 isAssociation]) ifTrue:[
         (e2 includes:e1) ifTrue:[
@@ -472,6 +473,11 @@
             ne size == 0 ifTrue:[^ nil].
             ^ ne
         ].
+        
+        idx := e2 findFirst:[:em | em isAssociation and:[em key == e1]].
+        idx ~~ 0 ifTrue:[
+            ^ e2 copyWithoutIndex:idx.
+        ].
         ^ e2
     ].
 
@@ -862,6 +868,14 @@
      ((Text string:'hello') emphasizeAllWith:#(bold italic))
         emphasisAllRemove:#italic
 
+     ((Text string:'hello') emphasizeAllWith:(Array with:#color->Color red
+                                                    with:#italic))
+        emphasisAllRemove:#italic
+
+     ((Text string:'hello') emphasizeAllWith:(Array with:#color->Color red
+                                                    with:#italic))
+        emphasisAllRemove:#color
+
      Transcript show:(((Text string:'hello') emphasizeAllWith:#(bold italic)) 
                         emphasisAllRemove:#italic)
     "
@@ -1319,6 +1333,6 @@
 !Text class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/Text.st,v 1.61 1999-08-18 14:32:01 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/Text.st,v 1.62 1999-10-13 22:37:50 cg Exp $'
 ! !
 Text initialize!