Index: /trunk/source/cocoa-ide/cocoa-editor.lisp
===================================================================
--- /trunk/source/cocoa-ide/cocoa-editor.lisp	(revision 14489)
+++ /trunk/source/cocoa-ide/cocoa-editor.lisp	(revision 14490)
@@ -1131,18 +1131,16 @@
                                                         
 
-
+;;; This assumes that NSBackgroundColorAttributeName can only be 
+;;; present id it's (possibly stale) paren highlighting info.
+;;; We can't be sure of the locations (because of insertions/deletions),
+;;; so remove the attribute from the entire textstorage.
 (defmethod remove-paren-highlight ((self hemlock-textstorage-text-view))
-  #-cocotron
-  (let* ((left (text-view-paren-highlight-left-pos self))
-         (right (text-view-paren-highlight-right-pos self)))
-    (ns:with-ns-range  (char-range left 1)
-      (let* ((layout (#/layoutManager self)))
-        (#/removeTemporaryAttribute:forCharacterRange: 
-         layout #&NSBackgroundColorAttributeName 
-         char-range)
-        (setf (pref char-range #>NSRange.location) right)
-        (#/removeTemporaryAttribute:forCharacterRange: 
-         layout #&NSBackgroundColorAttributeName 
-         char-range)))))
+  (let* ((textstorage (#/textStorage self))
+         (len (#/length textstorage)))
+    (#/beginEditing textstorage)
+    (ns:with-ns-range  (char-range 0 len)
+      (#/removeAttribute:range: textstorage #&NSBackgroundColorAttributeName
+                                char-range))
+    (#/endEditing textstorage)))
 
 (defmethod disable-paren-highlight ((self hemlock-textstorage-text-view))
@@ -1153,5 +1151,4 @@
 
 (defmethod compute-temporary-attributes ((self hemlock-textstorage-text-view))
-  #-cocotron
   (let* ((container (#/textContainer self))
          ;; If there's a containing scroll view, use its contentview         
@@ -1191,9 +1188,14 @@
 	     (attrs (#/dictionaryWithObject:forKey: ns:ns-dictionary
 						    paren-highlight-color
-						    background)))
-        (#/addTemporaryAttributes:forCharacterRange:
-         layout attrs (ns:make-ns-range paren-highlight-left 1))
-        (#/addTemporaryAttributes:forCharacterRange:
-         layout attrs (ns:make-ns-range paren-highlight-right 1))))))
+						    background))
+             (ts (#/textStorage self)))
+        (ns:with-ns-range (left-range paren-highlight-left 1)
+          (ns:with-ns-range (right-range paren-highlight-right 1)
+            (#/beginEditing ts)
+            (#/addAttributes:range: ts attrs left-range)
+            ;(#/edited:range:changeInLength: ts #$NSTextStorageEditedAttributes left-range 0)
+            (#/addAttributes:range: ts attrs right-range)
+            ;(#/edited:range:changeInLength: ts #$NSTextStorageEditedAttributes right-range 0)
+            (#/endEditing ts)))))))
 
 (defmethod update-paren-highlight ((self hemlock-textstorage-text-view))
@@ -1328,10 +1330,7 @@
                     (setf (ns:ns-range-location range) start
                           (ns:ns-range-length range) len)
-                    (let ((attrs (#/dictionaryWithObject:forKey:
-                                  ns:ns-dictionary
-                                  (if (eq type :string) string-color comment-color)
-                                  color-attribute)))
-                      (#/addTemporaryAttributes:forCharacterRange:
-                       layout attrs range)))
+                    (let ((attrs (if (eq type :string) string-color comment-color)))
+                      (#/addTemporaryAttribute:value:forCharacterRange:
+                       layout color-attribute attrs range)))
                   (setq last-end iend))))))))))
 
